str = input()

N = int(str.split()[0])
K = int(str.split()[1])
if (K == 1):
	s = 0
else :
	s = N - K

print("{}".format(s)) str = input() str input() input N = int(str.split()[0]) N int(str.split()[0]) int str.split()[0] str.split() str.split str split 0 K = int(str.split()[1]) K int(str.split()[1]) int str.split()[1] str.split() str.split str split 1 if (K == 1):
	s = 0
else :
	s = N - K K == 1 K 1 s = 0 s 0 s = N - K s N - K N K print("{}".format(s)) print "{}".format(s) "{}".format "{}" format s N = int(str.split()[0]) int(str.split()[0]) N str = input() input() str s = 0 0 s s = N - K N - K s K = int(str.split()[1]) int(str.split()[1]) K
str = input()

N = int(str.split()[0])
K = int(str.split()[1])
if (K == 1):
	s = 0
else :
	s = N - K

print("{}".format(s))
