a, b = map(int, input().split()) rem = a % b print(b if rem == 0 else rem)