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