print((eval(input())-eval(input()))%eval(input()))
i=input;print((eval(i()+'-'+i())%int(i())))
print((eval(input()) - eval(input())) % eval(input()))

i = input
print((eval(i() + "-" + i()) % int(i())))

-print((eval(input()) - eval(input())) % eval(input())) +i = input +print((eval(i() + "-" + i()) % int(i())))