s,k=map(int,raw_input().split()) print s%k