from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
if K == 1:
  print(0)
else:
  print(N-K) from sys import stdin int(_) for _ in stdin.readline().rstrip().split() for _ in stdin.readline().rstrip().split() _ stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for _ in stdin.readline().rstrip().split() int(_) int _ N, K = [int(_) for _ in stdin.readline().rstrip().split()] N [int(_) for _ in stdin.readline().rstrip().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 = [int(_) for _ in stdin.readline().rstrip().split()] [int(_) for _ in stdin.readline().rstrip().split()] N K = [int(_) for _ in stdin.readline().rstrip().split()] [int(_) for _ in stdin.readline().rstrip().split()] K
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
if K == 1:
  print(0)
else:
  print(N-K)