N,K = map(int,input().split())
if K >= 2:
  if N-K+1 >= 1:
    print(N-K)
  else:
    print(0)
else:
  print(0) N,K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K if K >= 2:
  if N-K+1 >= 1:
    print(N-K)
  else:
    print(0)
else:
  print(0) K >= 2 K 2 if N-K+1 >= 1:
    print(N-K)
  else:
    print(0) N-K+1 >= 1 N-K+1 N-K N K 1 1 print(N-K) print N-K N K print(0) print 0 print(0) print 0 N,K = map(int,input().split()) map(int,input().split()) N K = map(int,input().split()) map(int,input().split()) K
N,K = map(int,input().split())
if K >= 2:
  if N-K+1 >= 1:
    print(N-K)
  else:
    print(0)
else:
  print(0)