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