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