a,b=map(int,input().split())
c=a-b
if b!= 1:
	print(c)
else:
	print(0) a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c=a-b c a-b a b if b!= 1:
	print(c)
else:
	print(0) b!= 1 b 1 print(c) print c print(0) print 0 b=map(int,input().split()) map(int,input().split()) b a,b=map(int,input().split()) map(int,input().split()) a c=a-b a-b c
a,b=map(int,input().split())
c=a-b
if b!= 1:
	print(c)
else:
	print(0)