A, B = map(int, input().split()) flag = 0 if B < 0: A, B = -A, -B flag = 1 ans = A % B if flag: ans = B - ans print(ans)