import math A, B = map(int, input().split()) print(math.ceil(B%A))