N,K =map(int, raw_input().split(" "))


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

 N,K =map(int, raw_input().split(" ")) N map(int, raw_input().split(" ")) map int raw_input().split(" ") ().split () raw_input 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, raw_input().split(" ")) map(int, raw_input().split(" ")) N K =map(int, raw_input().split(" ")) map(int, raw_input().split(" ")) K
N,K =map(int, raw_input().split(" "))


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


