x = int(eval(input()))

a = int(eval(input()))

b = int(eval(input()))

print(((x - a) % b))
def main():

    x, a, b = (int(eval(input())) for _ in range(3))

    print(((x - a) % b))





if __name__ == '__main__':

    main()



# import sys

# input = sys.stdin.readline

# 

# sys.setrecursionlimit(10 ** 7)

# 

# (int(x)-1 for x in input().split())

# rstrip()

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

def main():
    x, a, b = (int(eval(input())) for _ in range(3))
    print(((x - a) % b))


if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()

-x = int(eval(input())) -a = int(eval(input())) -b = int(eval(input())) -print(((x - a) % b)) +def main(): +    x, a, b = (int(eval(input())) for _ in range(3)) +    print(((x - a) % b)) + + +if __name__ == "__main__": +    main() +# import sys +# input = sys.stdin.readline +# +# sys.setrecursionlimit(10 ** 7) +# +# (int(x)-1 for x in input().split()) +# rstrip()