S,K = map(int,raw_input().split()) print S % K