#!/usr/bin/env python3

# coding=utf-8



import sys



x = int(sys.stdin.readline().strip())

a = int(sys.stdin.readline().strip())

b = int(sys.stdin.readline().strip())



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

def solve(string):

    x, a, b = list(map(int, string.split()))

    return str((x - a) % b)





if __name__ == '__main__':

    n = 3

    print((solve('\n'.join([eval(input()) for _ in range(n)]))))

#!/usr/bin/env python3
# coding=utf-8
import sys

x = int(sys.stdin.readline().strip())
a = int(sys.stdin.readline().strip())
b = int(sys.stdin.readline().strip())
print(((x - a) % b))

def solve(string):
    x, a, b = list(map(int, string.split()))
    return str((x - a) % b)


if __name__ == "__main__":
    n = 3
    print((solve("\n".join([eval(input()) for _ in range(n)]))))

-#!/usr/bin/env python3 -# coding=utf-8 -import sys +def solve(string): +    x, a, b = list(map(int, string.split())) +    return str((x - a) % b) -x = int(sys.stdin.readline().strip()) -a = int(sys.stdin.readline().strip()) -b = int(sys.stdin.readline().strip()) -print(((x - a) % b)) + +if __name__ == "__main__": +    n = 3 +    print((solve("\n".join([eval(input()) for _ in range(n)]))))