
S = list(map(int, input().split()))

N = S[0]
K = S[1]


if N % K == 0:
    print(0)
else:
    print(N-K) S = list(map(int, input().split())) S list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N = S[0] N S[0] S 0 K = S[1] K S[1] S 1 if N % K == 0:
    print(0)
else:
    print(N-K) N % K == 0 N % K N K 0 print(0) print 0 print(N-K) print N-K N K N = S[0] S[0] N K = S[1] S[1] K S = list(map(int, input().split())) list(map(int, input().split())) S

S = list(map(int, input().split()))

N = S[0]
K = S[1]


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