N,K=map(int, input().split())

if K == 1:
  out =0
else:
  # 1以外
  nokori = N - K
  mx = nokori + 1
  mn = 1
  out = mx-mn

print(out) N,K=map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K == 1:
  out =0
else:
  # 1以外
  nokori = N - K
  mx = nokori + 1
  mn = 1
  out = mx-mn K == 1 K 1 out =0 out 0 nokori = N - K nokori N - K N K mx = nokori + 1 mx nokori + 1 nokori 1 mn = 1 mn 1 out = mx-mn out mx-mn mx mn print(out) print out mx = nokori + 1 nokori + 1 mx K=map(int, input().split()) map(int, input().split()) K nokori = N - K N - K nokori mn = 1 1 mn out = mx-mn mx-mn out N,K=map(int, input().split()) map(int, input().split()) N out =0 0 out
N,K=map(int, input().split())

if K == 1:
  out =0
else:
  # 1以外
  nokori = N - K
  mx = nokori + 1
  mn = 1
  out = mx-mn

print(out)
