n,k = map(int,input().split())

if k == 1:
   print(0)
else:
   g = n - (k - 1)
   if g == 1:
      print(0)
   elif g < 1:
      print(1)
   else:
      print(g-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:
   g = n - (k - 1)
   if g == 1:
      print(0)
   elif g < 1:
      print(1)
   else:
      print(g-1) k == 1 k 1 print(0) print 0 g = n - (k - 1) g n - (k - 1) n k - 1 k 1 if g == 1:
      print(0)
   elif g < 1:
      print(1)
   else:
      print(g-1) g == 1 g 1 print(0) print 0 elif g < 1:
      print(1)
    g < 1 g 1 print(1) print 1 print(g-1) print g-1 g 1 g = n - (k - 1) n - (k - 1) g 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())

if k == 1:
   print(0)
else:
   g = n - (k - 1)
   if g == 1:
      print(0)
   elif g < 1:
      print(1)
   else:
      print(g-1)