import sys
N, K = map(int, sys.stdin.readline().split())

if K == 1:
  print(0)
else:
  print(N-K) import sys sys N, K = map(int, sys.stdin.readline().split()) N map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split K 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, K = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) N K = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) K
import sys
N, K = map(int, sys.stdin.readline().split())

if K == 1:
  print(0)
else:
  print(N-K)