N = int(input())
A = int(input())
B = int(input())
print((N - A) % B)

df010cf166e2c75db3134992a117076990c335b9
<mask token>

<mask token>
print((N - A) % B)

N = int(input())
A = int(input())
B = int(input())
print((N - A) % B)
