a,b = list(map(int, input().split(' '))) # print(a%b) ans = a%b if ans < 0: ans -= b print(ans)