#https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_a

N,K = [int(i) for i in input().split()]
if K > 1:
    print(N-K)
else:
    print(0) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N,K = [int(i) for i in input().split()] N [int(i) for i in input().split()] K if K > 1:
    print(N-K)
else:
    print(0) K > 1 K 1 print(N-K) print N-K N K print(0) print 0 N,K = [int(i) for i in input().split()] [int(i) for i in input().split()] N K = [int(i) for i in input().split()] [int(i) for i in input().split()] K
#https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_a

N,K = [int(i) for i in input().split()]
if K > 1:
    print(N-K)
else:
    print(0)