x = int(eval(input()))

a = int(eval(input()))

b = int(eval(input()))



print(((x - a) % b))
x = int(eval(input()))

a = int(eval(input()))

b = int(eval(input()))

ans = (x-a) % b

print(ans)
x = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
print(((x - a) % b))

x = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
ans = (x - a) % b
print(ans)

-print(((x - a) % b)) +ans = (x - a) % b +print(ans)