x,a,b = [int(eval(input())) for i in range(3)]

print((x - a - b*((x-a)//b)))
x,a,b = [int(eval(input())) for i in range(3)]

print(((x-a)%b))
x, a, b = [int(eval(input())) for i in range(3)]
print((x - a - b * ((x - a) // b)))

x, a, b = [int(eval(input())) for i in range(3)]
print(((x - a) % b))

-print((x - a - b * ((x - a) // b))) +print(((x - a) % b))