line = input().split()
N = int(line[0])
K = int(line[1])
 
if K==1:
  ans = 0
else:
  ans = N-K
print(ans) line = input().split() line input().split() ().split () input split N = int(line[0]) N int(line[0]) int line[0] line 0 K = int(line[1]) K int(line[1]) int line[1] line 1 if K==1:
  ans = 0
else:
  ans = N-K K==1 K 1 ans = 0 ans 0 ans = N-K ans N-K N K print(ans) print ans ans = 0 0 ans ans = N-K N-K ans line = input().split() input().split() line N = int(line[0]) int(line[0]) N K = int(line[1]) int(line[1]) K
line = input().split()
N = int(line[0])
K = int(line[1])
 
if K==1:
  ans = 0
else:
  ans = N-K
print(ans)