from sys import stdin n,m =[int(x) for x in stdin.readline().rstrip().split()] print(n%m)