#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
if K == 1:
    print(0)
else:
    print(N-K) int(k) for k in input().split() for k in input().split() k input().split() ().split () input split for k in input().split() int(k) int k def inputlist(): return [int(k) for k in input().split()]
#template inputlist N,K = inputlist() N inputlist() inputlist 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 = inputlist() inputlist() N K = inputlist() inputlist() K def inputlist(): return [int(k) for k in input().split()]
#template def inputlist(): return [int(k) for k in input().split()]
#template inputlist
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
if K == 1:
    print(0)
else:
    print(N-K)