data = []

data.extend(list(map(int, input().split(" "))))
N = data[0]
K = data[1]

if K == 1:
    print(0)
else:
    print(N - K) data = [] data [] data.extend(list(map(int, input().split(" ")))) data.extend data extend list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " N = data[0] N data[0] data 0 K = data[1] K data[1] data 1 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 = data[0] data[0] N K = data[1] data[1] K data = [] [] data
data = []

data.extend(list(map(int, input().split(" "))))
N = data[0]
K = data[1]

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