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