Here's the algorithm to find the next beautiful year:
Start with year + 1 (the year after the input).
For each candidate year, extract all its digits using repeated modulo and division.
Check if all digits are distinct. You can use a set or an array of 10 booleans.
If all digits are distinct, you found the answer. Print it and stop.
If any digit repeats, increment the year and try again. Continue until you find a beautiful year. This brute force approach works because beautiful years aren't rare. You'll typically find one within a few thousand iterations, which runs instantly on modern computers.