#Takoma Park M.S.
#Int-3
#Contest 1
#Isabelle Yang

f = open("1int_testdata.txt", "r")
for line in f:
    data = line.split()
    number = list(data[0])
    p = int(data[1])
    digit = int(number[len(number) - p])
    
    for i in range(len(number)):
        number[i] = int(number[i])
        if i < len(number) - p:
            number[i] = str((number[i]+digit)%10)
        elif i == len(number) - p:
            number[i] = str(number[i])
        elif i > len(number) - p:
            number[i] = str((abs(number[i]-digit)%10))
    
    finalAnswer = ''.join(number)
    print(finalAnswer)
f.close()