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