for foo in range(5):
    x = input().split()
    num = x[0]
    ind = len(num) - int(x[1])
    p = int(num[ind])
    a = ''
    for i in num[:ind]:
        a += str((int(i) + p) % 10)
    a += str(p)
    if ind < len(num) - 1:
        for i in num[ind + 1:]:
            a += str(abs(int(i) - p))
    print(a)