Takahashi is distributing N balls to K persons.  If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
a,b=map(int,input().split())
if b==0:print(0)
else:print(b-a)
a,b=map(int,input().split())
if b==1:print(0)
else:print(a-b)
