l = input().split()
N = int(l[0])
K = int(l[1])

# print(N, K)

if K == 1:
    print(0)
    exit()

remain = N - K
print(remain) l = input().split() l input().split() ().split () input split N = int(l[0]) N int(l[0]) int l[0] l 0 K = int(l[1]) K int(l[1]) int l[1] l 1 if K == 1:
    print(0)
    exit() K == 1 K 1 print(0) print 0 exit() exit remain = N - K remain N - K N K print(remain) print remain K = int(l[1]) int(l[1]) K l = input().split() input().split() l remain = N - K N - K remain N = int(l[0]) int(l[0]) N
l = input().split()
N = int(l[0])
K = int(l[1])

# print(N, K)

if K == 1:
    print(0)
    exit()

remain = N - K
print(remain)
