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