# A - Ball Distribution
N, K = map(int, input().split())

if K == 1:
	print(0)
else:
	max = N - (K - 1)
	print(max - 1) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K == 1:
	print(0)
else:
	max = N - (K - 1)
	print(max - 1) K == 1 K 1 print(0) print 0 max = N - (K - 1) max N - (K - 1) N K - 1 K 1 print(max - 1) print max - 1 max 1 N, K = map(int, input().split()) map(int, input().split()) N max = N - (K - 1) N - (K - 1) max K = map(int, input().split()) map(int, input().split()) K
# A - Ball Distribution
N, K = map(int, input().split())

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