data = input()
datas = data.split(' ')

N = int(datas[0])
K = int(datas[1])

if K==1:
	print(0)
else:
	print(N-K) data = input() data input() input datas = data.split(' ') datas data.split(' ') data.split data split ' ' N = int(datas[0]) N int(datas[0]) int datas[0] datas 0 K = int(datas[1]) K int(datas[1]) int datas[1] datas 1 if K==1:
	print(0)
else:
	print(N-K) K==1 K 1 print(0) print 0 print(N-K) print N-K N K K = int(datas[1]) int(datas[1]) K N = int(datas[0]) int(datas[0]) N data = input() input() data datas = data.split(' ') data.split(' ') datas
data = input()
datas = data.split(' ')

N = int(datas[0])
K = int(datas[1])

if K==1:
	print(0)
else:
	print(N-K)