n and limit. Call a number **light** if the sum of its digits does not exceed limit.
Return the smallest non-negative integer x such that n + x is light. Such an x always exists.n=38, limit=5 → 2
38 has digit sum 11. Adding 2 gives 40 with digit sum 4 ≤ 5; adding less (39) only makes the sum bigger.
n=1995, limit=3 → 5
2000 is the first number at least 1995 whose digit sum is at most 3, so the answer is 5.
n=120, limit=3 → 0
The digit sum 1 + 2 + 0 = 3 already fits the limit, so nothing needs to be added.
n ≤ 10¹⁸limit ≤ 150n=38, limit=5
2
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.