while True:
	n, p = input('input = ').split()
	n = list(map(int, n))	
	p = len(n) - int (p)
	a = ''
	
	for i, v in enumerate(n):
		if i < p:
                        a += str((v + n[p]) % 10)
		elif i > p:
			a += str(abs(v - n[p]))
		else:
			a += str(n[p])

	print(a)