n, k = (int(i) for i in input().split()) 


# 89 人　は一つしか貰えないが、１人は11個もらえる
 
others = k - 1  # 最大限に貰えないひとたちの人数
min_num = 1
max_num = n - others
 

if k < 2:
    print(0)
else:
    print(max_num - min_num) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, k = (int(i) for i in input().split()) n (int(i) for i in input().split()) k others = k - 1 others k - 1 k 1 min_num = 1 min_num 1 max_num = n - others max_num n - others n others if k < 2:
    print(0)
else:
    print(max_num - min_num) k < 2 k 2 print(0) print 0 print(max_num - min_num) print max_num - min_num max_num min_num n, k = (int(i) for i in input().split()) (int(i) for i in input().split()) n max_num = n - others n - others max_num min_num = 1 1 min_num k = (int(i) for i in input().split()) (int(i) for i in input().split()) k others = k - 1 k - 1 others
n, k = (int(i) for i in input().split()) 


# 89 人　は一つしか貰えないが、１人は11個もらえる
 
others = k - 1  # 最大限に貰えないひとたちの人数
min_num = 1
max_num = n - others
 

if k < 2:
    print(0)
else:
    print(max_num - min_num)