N,K = map(int,raw_input().split()) print 0 if K == 1 else N+1-K