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