A, B = map(int, input().split()) ans = A % B if ans < 0: ans += abs(B) print(ans)