rr = raw_input
rrm = lambda: map(int, rr().split())

N, K = rrm()

N -= K
if K == 1:
    print 0
else:
    print N
     rr = raw_input rr raw_input rrm = lambda: map(int, rr().split()) rrm lambda: map(int, rr().split()) map(int, rr().split()) map int rr().split() ().split () rr split N, K = rrm() N rrm() rrm K N -= K N K if K == 1:
    print 0
else:
    print N
     K == 1 K 1 print print rrm = lambda: map(int, rr().split()) lambda: map(int, rr().split()) rrm rr = raw_input raw_input rr N -= K K N K = rrm() rrm() K N, K = rrm() rrm() N
rr = raw_input
rrm = lambda: map(int, rr().split())

N, K = rrm()

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