import numpy as np



X = int(eval(input()))

A = int(eval(input()))

B = int(eval(input()))



X -= A

n = int(X / B)

print((X - n*B))

X = int(eval(input()))

A = int(eval(input()))

B = int(eval(input()))



X -= A

n = int(X / B)

print((X - n*B))

import numpy as np

X = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
X -= A
n = int(X / B)
print((X - n * B))

X = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
X -= A
n = int(X / B)
print((X - n * B))

-import numpy as np -