s = input().split(" ")
n = int(s[0])
m = int(s[1])
if m==1:
  print(0)
else:
  print(n-m) s = input().split(" ") s input().split(" ") ().split () input split " " n = int(s[0]) n int(s[0]) int s[0] s 0 m = int(s[1]) m int(s[1]) int s[1] s 1 if m==1:
  print(0)
else:
  print(n-m) m==1 m 1 print(0) print 0 print(n-m) print n-m n m n = int(s[0]) int(s[0]) n s = input().split(" ") input().split(" ") s m = int(s[1]) int(s[1]) m
s = input().split(" ")
n = int(s[0])
m = int(s[1])
if m==1:
  print(0)
else:
  print(n-m)