abcd - bcda = 5800
1000a + 100b + 10c + d - (1000b + 100c + 10d + a) = 5800
1000a + 100b + 10c + d - 1000b - 100c - 10d - a = 5800
1000a - a + 100b - 1000b + 10c - 100c + d - 10d = 5800
999a - 900b - 90c - 9d = 5800
9 x (111a - 100b - 10c - d) = 5800