n,k=map(int,input().split())
xs=[1]*k
xs[0]+=n-k
print(max(xs)-min(xs))
 n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k xs=[1]*k xs [1]*k [1] 1 k xs[0]+=n-k xs[0] xs 0 n-k n k print(max(xs)-min(xs)) print max(xs)-min(xs) max(xs) max xs min(xs) min xs xs=[1]*k [1]*k xs k=map(int,input().split()) map(int,input().split()) k n,k=map(int,input().split()) map(int,input().split()) n
n,k=map(int,input().split())
xs=[1]*k
xs[0]+=n-k
print(max(xs)-min(xs))

