N, M = map(int, input().split())

if N % M == 0:
    print(0)
else :
    print(N-M) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M if N % M == 0:
    print(0)
else :
    print(N-M) N % M == 0 N % M N M 0 print(0) print 0 print(N-M) print N-M N M M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())

if N % M == 0:
    print(0)
else :
    print(N-M)
