<filename>abc192/c.py
n, k = map(int, input().split())
for i in range(k):
    n = int("".join((sorted(list(str(n)), reverse=True)))) - \
        int("".join((sorted(list(str(n))))))
print(n)

<filename>abc192/c.py
n, k = map(int, input().split())
for i in range(k):
    n = int("".join((sorted(list(str(n)), reverse=True)))) - \
        int("".join((sorted(list(str(n))))))
print(n)
