You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?
X = int(input())
A = int(input())
B = int(input())

money = X - A
n = 1
if money >0 :
    money= money - n*B
    n+=1
else:
    print(money)
print(money)
X = int(input())
A = int(input())
B = int(input())

m = int((X-A)/B)
print (X-A-m*B)