A, B = map(int, input().split()) remainder = A % B if remainder < 0: remainder += abs(B) print(remainder)