s, k = map(int, input().split()) print(s%k)