first=input() split_first=first.split() a=int(split_first[0]) b=int(split_first[1]) if b%a==0: print(a%b) else: print(int(a%b)+1)