A, B = map(int, input().split()) A = abs(A) B = abs(B) print(A%B)