A, B = map(int, input().split()) A += B*10**18 print(abs(A%abs(B)))