x,y = input().split()
N = int(x)
K = int(y)
if K == 1:
  print(0)
else:
  print(N-K) x,y = input().split() x input().split() ().split () input split y N = int(x) N int(x) int x K = int(y) K int(y) int y if K == 1:
  print(0)
else:
  print(N-K) K == 1 K 1 print(0) print 0 print(N-K) print N-K N K N = int(x) int(x) N y = input().split() input().split() y x,y = input().split() input().split() x K = int(y) int(y) K
x,y = input().split()
N = int(x)
K = int(y)
if K == 1:
  print(0)
else:
  print(N-K)
