S, K = map(int, input().split()) print(S%K)