# -----------------------------------------------------------------------------------------
# Oak Valley Coding Club 2019-2020
# Solution for 2020 ACSL Programming Problem #1 – Junior Division
# Author :  Mihir Sood
# Language: Python 3.x
# -----------------------------------------------------------------------------------------


#-----------------------------------------------
# Main Function to solve the problem
def transform(N,P,D):
    strN = str(N)
    listN = list(strN)
    MinP = -P
    NP = strN[MinP]
    NPD = 0
    counter = -1
    if int(NP) <= 4:
        NPD = int(NP) + D
        listN[MinP] = str(NPD)[-1]

    else:
        NPD = abs(int(NP) - D)
        listN[MinP] = str(NPD)[0]
    if MinP != -1:
        while True:
            listN[counter] = '0'
            counter = counter -1
            if NP == strN[counter]:
                break
            
    return int("".join(listN))


#-----------------------------------------------
# Auxiliary code for reading input and writing output
input = 'input.txt'
output = 'output.txt'

def readinput():
  words=[]
  with open(input) as f:
    lines = f.readlines()
    for line in lines:
      if line.split()!=[]:
        words.append(line.split())
  for j in range (0,len(words)):
    for i in range(0,len(words[j])):
      words[j][i]=int(words[j][i])
  return words


def writeoutput(line):
  with open(output,'a') as f:
     f.write(str(line)+'\n')

def clearoutput():
  f=open(output,'w')
  f.write('')

allinputs = readinput()

clearoutput()
for line in allinputs:
    N = line[0]
    P = line[1]
    D = line[2]
    out = transform(N, P, D)
    writeoutput(out)