while True:
    line = input().split()

    n = int(line[0])
    nStr = line[0]
    pIndex = len(nStr) - int(line[1])
    p = int(nStr[pIndex])

    for i in range(0, len(nStr)):
        if i < pIndex:
            newDigit = str((int(nStr[i]) + p) % 10)
            nStr = nStr[:i] + newDigit + nStr[i+1:]
            n = int(nStr)
        elif i > pIndex:
            newDigit = str(abs(int(nStr[i]) - p))
            nStr = nStr[:i] + newDigit + nStr[i+1:]
        n = int(nStr)

    print(n)