from itertools import permutations



def next_highest(num):
    perms = [''.join(p) for p in permutations(str(num))]
    perms = list(map(int, perms))
    perms = [x for x in perms if x > num]
    print(min(perms))

next_highest(1234)
next_highest(1243)
next_highest(234765)
next_highest(19000)