It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.


-----Input-----

The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.


-----Output-----

Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.


-----Examples-----
Input
1987

Output
2013

Input
2013

Output
2014

Difficulty: EASY

Solutions:
ano = input()
novoAno = ano
while True:
	if novoAno != ano and novoAno[0] != novoAno[1] and (novoAno[0] != novoAno[2]) and (novoAno[0] != novoAno[3]) and (novoAno[1] != novoAno[2]) and (novoAno[1] != novoAno[3]) and (novoAno[2] != novoAno[3]):
		print(novoAno)
		break
	else:
		aux = int(novoAno)
		aux += 1
		novoAno = str(aux)


n = input()
while True:
	n = str(int(n) + 1)
	if len(set(n)) == 4:
		break
print(n)


a = int(input())

def f(n):
	b = list(str(n + 1))
	digits = []
	for i in b:
		digits.append(i)
	digits = set(digits)
	if len(digits) == len(b):
		return n + 1
	else:
		return f(n + 1)
print(f(a))


n = int(input())
n += 1
l = len(str(n))
x = True
while x:
	s = str(n)
	v = set(s)
	if l == len(v):
		break
	n += 1
print(n)


y = input()
output = int(y)
while True:
	output += 1
	if len(set(str(output))) == len(y):
		print(output)
		break


year = input()
while 1:
	year = int(year) + 1
	year = str(year)
	for i in year:
		if year.count(i) > 1:
			flag = 0
			break
		else:
			flag = 1
	if flag == 1:
		print(int(year))
		break


a = int(input())
b = len(list(str(a)))
while True:
	a += 1
	if len(set(str(a))) == b:
		print(a)
		break


ans = ''

def isDiff(x):
	y = []
	for i in range(len(x)):
		if x[i] in y:
			break
		else:
			y.append(x[i])
	if len(y) == len(x):
		ans = x
		return True
	else:
		return False
n = int(input())
for i in range(n + 1, 10000):
	if isDiff(str(i)):
		print(i)
		break


n = int(input())
while 1:
	n = n + 1
	s = str(n)
	f = 1
	l = []
	for j in s:
		if j in l:
			f = 0
			break
		else:
			l.append(j)
	if f:
		print(n)
		break


a = int(input())
for i in range(8000):
	a = int(a)
	a += 1
	a = str(a)
	A = []
	for i in a[:]:
		A.append(i)
	p = 0
	for i in A:
		count = A.count(i)
		if count == 1:
			p += 1
		else:
			pass
	if p == 4:
		print(a)
		exit()
	else:
		pass


a = int(input())
a >= 1000
a <= 9000
for i in range(a + 1, a + 1000):
	b = str(i)
	k = len(b)
	j = len(set(b))
	if j == k:
		print(i)
		break


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def main():
	n = I()
	while True:
		n += 1
		if len(set(list(str(n)))) == 4:
			break
	print(n)
main()


an = input()
i = int(an)
i += 1
an = str(i)
dif = False
while dif == False:
	if an[0] != an[1] and an[0] != an[2] and (an[0] != an[3]):
		if an[1] != an[0] and an[1] != an[2] and (an[1] != an[3]):
			if an[2] != an[1] and an[2] != an[0] and (an[2] != an[3]):
				if an[3] != an[1] and an[3] != an[2] and (an[3] != an[0]):
					print(i)
					exit(0)
	i += 1
	an = str(i)


n = int(input())

def good(n):
	s = set()
	for i in range(4):
		s.add(n % 10)
		n //= 10
	return len(s) == 4
n += 1
while True:
	if good(n):
		print(n)
		break
	n += 1


def chk(n):
	d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while n > 0:
		if d[n % 10] > 0:
			return True
		d[n % 10] = 1
		n //= 10
	return False

def nice(n):
	while chk(n):
		n += 1
	return n
print(nice(int(input()) + 1))


year = input()
result = int(year) + 1
while True:
	set1 = set(str(result))
	result = int(result)
	if len(set1) != 4:
		result += 1
		continue
	else:
		break
print(result)


x = input()
while 1:
	x = str(int(x) + 1)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		print(x)
		raise SystemExit


yearinput = input()
from itertools import count
for num in count(int(yearinput) + 1):
	lll = list()
	for number in str(num):
		lll.append(number)
	sss = set(lll)
	if len(sss) == len(lll):
		print(num)
		break


y = int(input())
z = str(y + 1)
while z.count(z[0]) > 1 or z.count(z[1]) > 1 or z.count(z[2]) > 1 or (z.count(z[3]) > 1):
	z = str(int(z) + 1)
print(z)


def isdist(n):
	k = str(n)
	if len(k) == len(set(k)):
		return True
	return False
n = int(input())
stat = False
x = n + 1
while True:
	if isdist(x):
		print(x)
		break
	x += 1


a = int(input())
a += 1

def find(a):
	s = str(a)
	for i in s:
		if s.count(i) > 1:
			return 0
	return 1
while find(a) != 1:
	a += 1
print(a)


n = int(input())
while True:
	n += 1
	if str(n)[0] == str(n)[1] or str(n)[0] == str(n)[2] or str(n)[0] == str(n)[3] or (str(n)[1] == str(n)[2]) or (str(n)[1] == str(n)[3]) or (str(n)[2] == str(n)[3]):
		continue
	else:
		break
print(n)


s = int(input())
l = []
flag = 0
s += 1
while True:
	dummy = s
	while dummy != 0:
		l.append(dummy % 10)
		dummy //= 10
	l.sort()
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			flag = 1
	if flag == False:
		break
	flag = 0
	s += 1
	l.clear()
print(s)


y = str(int(input()) + 1)
while len(set([a for a in y])) != 4:
	y = str(int(y) + 1)
print(y)


n = int(input()) + 1

def cif(x):
	return n // 10 ** x % 10

def spis():
	s = []
	for i in range(4):
		s.append(cif(i))
	it = 0
	for i in range(4):
		for j in range(4):
			if i != j and s[i] - s[j] == 0:
				it = it + 1
	return it
spis()
while spis() != 0:
	n = n + 1
	spis()
print(n)


from collections import Counter
x = int(input())
while True:
	x = x + 1
	if len(Counter(str(x)).values()) == len(str(x)):
		print(x)
		break
	else:
		continue


n = int(input())
while 1:
	n += 1
	s = str(n)
	if len(list(s)) == len(set(list(s))):
		print(n)
		break


y = int(input())
x = y + 1
while True:
	dig = list(str(x))
	if len(set(dig)) == len(dig):
		print(x)
		break
	x += 1


yr = int(input())
while True:
	yr += 1
	a = yr % 10
	b = yr // 10 % 10
	c = yr // 100 % 10
	d = yr // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(yr)


num = int(input()) + 1

def differentDigits(num):
	digits = []
	numb = str(num)
	for i in range(len(numb)):
		if numb[i] not in digits:
			digits.append(numb[i])
		else:
			return False
	return True
while differentDigits(num) != True:
	num += 1
print(num)


n = int(input())
n += 1

def check(n: int):
	n = list(str(n))
	if len(n) == len(set(n)):
		return True
	else:
		return False
while check(n) != True:
	n += 1
print(n)


year = int(input())
while True:
	year += 1
	if len(str(year)) == len(set(str(year))):
		print(int(year))
		break


year = int(input()) + 1

def cool_year(year):
	str_year = str(year)
	set_year = set(str_year)
	if len(set_year) == 4:
		return True
	else:
		return False
while 1:
	if cool_year(year) == True:
		print(year)
		break
	elif cool_year(year) == False:
		year += 1


n = int(input(''))
i = 0
list = []
flag = 0
n += 1
while i <= i:
	a = str(n)
	flag = 0
	for x in a:
		c = int(x)
		if c in list:
			flag = 1
		else:
			list.append(int(x))
	if flag == 0:
		break
	else:
		n += 1
		del list[0:]
print(n)


def ok(y):
	y = str(y)
	a = [0] * 10
	for i in y:
		a[int(i)] += 1
	if 2 in a or 3 in a or 4 in a:
		return False
	return True
y = int(input())
for i in range(y + 1, 9999):
	if ok(i):
		print(i)
		exit()


n = int(input())
while 1:
	n += 1
	a = 1
	s = str(n)
	s = list(s)
	for i in range(0, len(s)):
		if s.count(s[i]) != 1:
			a = 0
			continue
	if a == 1:
		print(n)
		break


n = int(input())
n = n + 1
j = str(n)
s = list(j)
i = 0
s2 = sorted(s)
while i == 0:
	if s2[0] != s2[1] != s2[2] != s2[3]:
		i += 1
	else:
		n = n + 1
		j = str(n)
		s = list(j)
		s2 = sorted(s)
		i = 0
print(n)


oy = input()
noy = int(oy)
nny = noy + 1
while True:
	if len(set(str(nny))) >= len(str(nny)):
		print(nny)
		break
	else:
		nny += 1


a = input()
a = str(int(a) + 1)
while len(set(list(a))) != 4:
	a = str(int(a) + 1)
print(a)


number = int(input())
number += 1
distinct = False
while not distinct:
	s = []
	a = str(number)
	for i in range(0, len(a)):
		s.append(a[i])
	if len(set(s)) == len(s):
		distinct = True
	else:
		number += 1
print(str(number))


n = int(input())
a = []
b = []
z = n + 1
k = set(b)
for i in str(n):
	a.append(i)
while len(a) != len(k):
	for j in str(z):
		b.append(j)
	z += 1
	k = set(b)
	b = []
print(z - 1)


y = int(input())
for i in range(y + 1, y + 1000):
	a = str(i)[0]
	b = str(i)[1]
	c = str(i)[2]
	d = str(i)[3]
	if a != b and b != c and (c != d) and (a != c) and (a != d) and (b != d):
		print(i)
		break


year = int(input())
num = []
loop = True
while loop == True and year <= 9012:
	year += 1
	num.append(str(year)[0])
	num.append(str(year)[1])
	num.append(str(year)[2])
	num.append(str(year)[3])
	if num.count(num[0]) == 1 and num.count(num[1]) == 1 and (num.count(num[2]) == 1) and (num.count(num[3]) == 1):
		loop = False
	else:
		loop = True
		num.clear()
print(num[0] + num[1] + num[2] + num[3])


s = int(input())
s += 1
s = list(str(s))

def c(s):
	for i in s:
		if s.count(i) > 1:
			return False
	return True
count = 0
while c(s) != True:
	s = int(''.join(s))
	s += 1
	s = list(str(s))
print(''.join(s))


s = int(input())
for i in range(s):
	s += 1
	if len(set(str(s))) == 4:
		print(s)
		break


y = int(input())
r = y + 1
while len(set(str(r))) < 4:
	r += 1
print(r)


def check(n):
	p = str(n)
	for i in range(4):
		l = p.count(p[i])
		if l == 1:
			flag = True
		else:
			flag = False
			break
	return flag
y = int(input())
if check(y):
	y = y + 1
while True:
	if check(y):
		print(y)
		break
	else:
		y = y + 1


n = int(input())
i = n + 1
while i <= 90000:
	if len(set(str(i))) >= len(str(n)):
		print(i)
		break
	i += 1


b = []
a = input()
a = str(int(a) + 1)
for i in a:
	b.append(i)
b = set(b)
while len(b) < 4:
	b = []
	a = str(int(a) + 1)
	for i in a:
		b.append(i)
	b = set(b)
print(a)


year = int(input())
while year <= 10000:
	year += 1
	year_text = str(year)
	digits = set()
	for digit in year_text:
		digits.add(digit)
	if len(digits) == 4:
		break
print(year)


a = int(input())
n = '1234567890'
sigo = 1
while sigo:
	a = a + 1
	z = 0
	s = str(a)
	for l in n:
		if l in s:
			z = z + 1
	if z == 4:
		print(a)
		sigo = False


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
s = str(input())
n = int(s)
n = n + 1
while True:
	s1 = str(n)
	if s1[0:1] != s1[1:2] and s1[0:1] != s1[2:3] and (s1[0:1] != s1[3:4]) and (s1[1:2] != s1[3:4]) and (s1[2:3] != s1[1:2]) and (s1[2:3] != s1[3:4]):
		break
	else:
		n = n + 1
print(n)


import sys
input = sys.stdin.readline

def main():
	y = int(input())
	while 1:
		y += 1
		if len(set(list(str(y)))) == 4:
			print(y)
			return
main()


import math

def isok(n):
	s = [-1]
	while n > 0:
		if n % 10 in s:
			return 0
		s.append(n % 10)
		n = n // 10
	return 1
n = int(input())
while True:
	n += 1
	if isok(n):
		break
print(n)


year = int(input())
for i in range(year + 1, 9013):
	check_duplication = set(str(i))
	if len(check_duplication) == 4:
		print(i)
		break


y = int(input())
while True:
	y += 1
	l = [int(i) for i in list(str(y))]
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
		print(y)
		break


n = int(input())
ny = n + 1
if len(set(str(ny))) == len(list(str(ny))):
	print(ny)
else:
	i = 0
	while len(set(str(ny))) != len(list(str(ny))):
		ny += 1
	print(ny)


q = int(input())
while 1:
	q = str(q + 1)
	if len(set(q)) == len(q):
		break
	q = int(q)
print(q)


num = int(input())
if 1987 <= num < 2013:
	print(2013)
else:
	num += 1
	while len(str(num)) != len(set(str(num))):
		num += 1
	print(num)


n = int(input())
for i in range(n + 1, 9999):
	str_ = str(i)
	set_ = set(str_)
	if len(set_) != 4:
		continue
	else:
		break
print(i)


n = int(input())
for i in range(n + 1, 9999):
	l = list(str(i))
	dic = {}
	for j in range(4):
		if l[j] not in dic:
			dic[l[j]] = i
	if len(dic) == 4:
		print(i)
		break


def neweve(n):
	a = ''
	for i in range(len(n)):
		if n[i] not in a:
			a = a + n[i]
			if len(a) == len(n):
				print(n)
		else:
			n = str(int(n) + 1)
			neweve(n)
			break
y = int(input())
n = str(y + 1)
neweve(n)


n = int(input())

def distict_year(a):
	if len(a) == len(set(a)):
		return 1
	else:
		return 0
while 1:
	n = n + 1
	a = [int(x) for x in str(n)]
	if distict_year(a):
		print(int(''.join([str(x) for x in a])))
		break
	else:
		continue


s = list(input())
si = int(''.join(s))
for i in range(si + 1, 9050):
	slist = list(str(i))
	a = []
	for j in slist:
		if j not in a:
			a.append(j)
	if len(a) == 4:
		print(''.join(a))
		break
	a.clear()


def distinct_digits(num):
	if len(set(list(str(num)))) == len(str(num)):
		return True
	return False

def larger_num(num):
	num += 1
	while not distinct_digits(num):
		num += 1
	return num
print(larger_num(int(input())))


s = str(input())
d = str(int(s) + 1)
e = len(set(str(d)))
if e == 4:
	print(d)
else:
	while e < 4:
		d = str(int(d) + 1)
		e = len(set(d))
		if e == 4:
			print(d)
			break


n = int(input()) + 1
cond = True
while cond:
	year = str(n)
	if len(year) == len(set(year)):
		cond = False
		print(year)
	n += 1


n = int(input())
for i in range(n + 1, 9000000000000):
	s = str(i)
	l = set(s)
	if len(l) == 4:
		print(s)
		break


n = int(input())
while True:
	n += 1
	n = str(n)
	k = set()
	for i in n:
		k.add(i)
	if len(k) == len(n):
		print(n)
		break
	n = int(n)


a = int(input())
a = a + 1
a = str(a)
for i in range(8001):
	s = set(a)
	if len(s) == 4:
		print(a)
		break
	else:
		a = int(a)
		a = a + 1
		a = str(a)


n = int(input())
a = n
a = str(int(a) + 1)
while len(set(a)) != len(str(n)):
	a = int(a)
	a += 1
	a = str(a)
print(a)


y = str(int(input()) + 1)
while True:
	if len(set(y)) == 4:
		print(y)
		break
	else:
		y = str(int(y) + 1)


year = int(input()) + 1
while True:
	str_year = str(year)
	if any((str_year.count(digit) != 1 for digit in str_year)):
		year += 1
	else:
		break
print(year)


a = int(input())
a += 1
while True:
	b = []
	for c in str(a):
		b.append(int(c))
	b = set(b)
	if len(b) == 4:
		print(a)
		break
	a += 1


def port(n):
	c = n
	bt = 0
	for i in range(10):
		t = 0
		a = n
		while a != 0:
			y = a % 10
			a = a // 10
			if i == y:
				t = t + 1
			if t > bt:
				bt = t
	if bt == 1:
		return c
	else:
		return -1
n = int(input())
a = n + 1
while port(a) == -1:
	a = a + 1
print(a)


def valid(a):
	a = [int(i) for i in str(a)]
	a.sort()
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			return False
	return True
a = int(input().strip()) + 1
while not valid(a):
	a += 1
print(a)


import re
n = input()
x = int(n)
for i in range(x + 1, 10000):
	m = str(i)
	a = re.findall('[0]', m)
	b = re.findall('[1]', m)
	c = re.findall('[2]', m)
	d = re.findall('[3]', m)
	e = re.findall('[4]', m)
	f = re.findall('[5]', m)
	g = re.findall('[6]', m)
	h = re.findall('[7]', m)
	j = re.findall('[8]', m)
	k = re.findall('[9]', m)
	if len(a) > 1 or len(b) > 1 or len(c) > 1 or (len(d) > 1) or (len(e) > 1) or (len(f) > 1) or (len(g) > 1) or (len(h) > 1) or (len(j) > 1) or (len(k) > 1):
		continue
	else:
		print(i)
		break


a = input()
st = a
count = 0
while True:
	st = int(st) + 1
	st = str(st)
	for i in range(len(st)):
		val = st[i]
		comp = st[0:i] + st[i + 1:len(st)]
		if val not in comp:
			count += 1
	if count == len(st):
		break
	else:
		count = 0
print(st)


y = int(input())

def beautiful(x):
	c = [0] * 10
	for i in str(x):
		c[int(i)] += 1
	for i in c:
		if i > 1:
			return False
	return True
ans = y + 1
while not beautiful(ans):
	ans = ans + 1
print(ans)


n = input()
n = str(int(n) + 1)
while len(''.join(set(n))) != 4:
	n = str(int(n) + 1)
print(n)


inp = input()
inp = int(inp) + 1
while len(list(dict.fromkeys(list(str(inp))))) != 4:
	inp = int(inp)
	inp += 1
print(inp)


x = input()
x = int(x) + 1
x = str(x)
while True:
	q = []
	for i in x:
		q.append(str(i))
	p = q
	q = set(q)
	if len(q) == len(p):
		a = ''.join(p)
		print(a)
		break
	x = int(x)
	x += 1
	x = str(x)


y = input()
while True:
	y = str(int(y) + 1)
	a = set(list(y))
	if len(a) == 4:
		break
print(y)


n = int(input())
b = set()
l = 0
while l != 4:
	n += 1
	x = str(n)
	b = set()
	b.update(x)
	l = len(b)
print(n)


year = int(input()) + 1

def is_cute(year):
	return len(set(year)) == 4
while not is_cute(str(year)):
	year += 1
print(year)


a = input()
l1 = list(a)
num = int(a)
list1 = list(set(l1))
while list1 != l1:
	num += 1
	l1 = list(str(num))
	l1.sort()
	list1 = list(set(l1))
	list1.sort()
print(num)


year = int(input())

def y(year):
	while True:
		year += 1
		if len(set(str(year))) == 4:
			return year
print(y(year))


def isBeautiful(year):
	year = str(year)
	s = set()
	for i in range(len(year)):
		s.add(year[i])
	if len(s) == len(year):
		return True
	else:
		return False
year = int(input())
year = year + 1
while not isBeautiful(year):
	year = year + 1
print(year)


y = int(input()) + 1
while len(set(str(y))) != len(str(y)):
	y += 1
print(y)


from math import *
x = int(input())
while 1:
	x = x + 1
	a = floor(x / 1000)
	b = floor(x / 100) - a * 10
	c = floor(x / 10) - (a * 10 + b) * 10
	d = x - (a * 1000 + b * 100 + c * 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		sum = x
		break
print(sum)


y = int(input()) + 1
while len(set(list(str(y)))) != 4:
	y += 1
print(y)


n = int(input())
numbers = []
for i in range(10):
	numbers.append(str(i))
num = {}
m = n + 1
while True:
	flag = 0
	for i in numbers:
		num[i] = 0
	l = list(str(m))
	for k in l:
		num[k] += 1
	for k in l:
		if num[k] > 1:
			flag = 1
			break
	if flag == 0:
		print(m)
		break
	m = m + 1


year = int(input()) + 1
while True:
	if year < 1000 or year > 9013:
		break
	li = list()
	temp = year
	while temp > 0:
		li.append(temp % 10)
		temp = temp // 10
	if len(li) == len(set(li)):
		print(year)
		break
	year += 1


n = int(input())
flag = 0
n = n + 1
while flag == 0:
	a = list(map(int, str(n)))
	cnt = 0
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			if a[i] == a[j]:
				cnt = cnt + 1
	if cnt == 0:
		flag = 1
		print(''.join(map(str, a)))
	else:
		flag = 0
		n = n + 1


t = int(input())
while t < 10000:
	t += 1
	x = set(list(str(t)))
	if len(x) == 4:
		print(t)
		break


year = int(input())
years = []
for i in range(1000, 9100):
	a = list(str(i))
	num = list('0123456789')
	for j in a:
		if j in num:
			num.remove(j)
	if len(num) == 6:
		years.append(i)
for yea in years:
	if yea > year:
		print(yea)
		break


n = input()
while True:
	n = f'{int(n) + 1}'
	if not (n[3] in n[:3] or n[2] in n[:2] or n[1] in n[:1]):
		print(n)
		break


a = int(input()) + 1
b = set(str(a))
while len(b) < 4:
	a += 1
	b = set(str(a))
print(a)


y = int(input())
w = 1
while w == 1:
	y += 1
	a = str(y)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[2] != a[1]) and (a[3] != a[1]) and (a[3] != a[2]):
		w = 0
print(y)


for i in range(int(input()) + 1, 9013):
	if len(set(list(str(i)))) == 4:
		print(i)
		break


yr = int(input())
yrz = str(yr + 1)
while len(list(yrz)) != len(set(list(yrz))):
	yrz = str(int(yrz) + 1)
print(yrz)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
num = n + 1
while len(set(list(str(num)))) != 4:
	num += 1
print(int(num))


x = int(input())
s = str(x)
while 1:
	x += 1
	s = str(x)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		exit(0)


y = int(input())
z = y + 1
pic = set(str(z))
arr = list(str(y))
while len(arr) != len(pic):
	z += 1
	pic = set(str(z))
print(z)


def main():
	year = int(input()) + 1
	while len(set(str(year))) != len(str(year)):
		year += 1
	print(year)
main()


y = int(input())
for i in range(y + 1, 10000):
	c = str(i)
	s = set(c)
	if len(s) == 4:
		print(i)
		break


n = int(input())
a = False
while a == False:
	n += 1
	x = str(n)
	if x[0] != x[1] and x[1] != x[2] and (x[2] != x[3]) and (x[0] != x[3]) and (x[0] != x[2]) and (x[1] != x[3]):
		a = True
print(n)


year = int(input())
i = year + 1
while 1:
	arr_year = [str(i)[knt] for knt in range(len(str(i)))]
	if len(set(arr_year)) == 4:
		print(i)
		break
	i += 1


n = int(input())
lent = len(str(n))
while True:
	n = int(n)
	n += 1
	n = str(n)
	a = set(n)
	if len(a) == lent:
		print(n)
		break


def main():
	n = int(input())
	i = n + 1
	while True:
		numbers = set(str(i))
		if len(numbers) == len(str(i)):
			print(i)
			exit()
		else:
			i += 1
main()


a = False
x = int(input())
z = 0
while not a:
	z += 1
	w = x + z
	a1 = w // 1000
	a2 = w // 100 - w // 1000 * 10
	a3 = w // 10 - w // 100 * 10
	a4 = w % 10
	if a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a2 != a4) and (a3 != a4):
		a = True
		t = w
print(t)


n = int(input())
for i in range(1, 9000):
	c = n + i
	k = list(str(c))
	k = list(dict.fromkeys(k))
	if len(k) == 4:
		print(c)
		break


year = int(input())
output = str(year + 1)
while output.count(output[0]) > 1 or output.count(output[1]) > 1 or output.count(output[2]) > 1 or (output.count(output[3]) > 1):
	output = str(int(output) + 1)
print(output)


def check_distinct(year):
	string = str(year)
	for s in string:
		if string.count(s) > 1:
			return False
	return True
year = int(input()) + 1
while check_distinct(year) is False:
	year += 1
print(year)


import sys

def main():
	inp = sys.stdin.readlines()
	year_in = int(inp[0])
	while True:
		year_in += 1
		year_out = str(year_in)
		set_of_no = set()
		for no in year_out:
			set_of_no.add(no)
		if len(set_of_no) == 4:
			print(year_out)
			break
main()


def cnt(x):
	return len(set(list(x)))
k = int(input())
while True:
	k += 1
	x = cnt(str(k))
	if x == 4:
		print(str(k))
		break


n = int(input()) + 1
while n > 0:
	if len(set(str(n))) == 4:
		print(n)
		break
	else:
		n += 1


def find_beutiful(y):
	while True:
		y += 1
		x = str(y)
		if len(set(x)) == len(x):
			return y
n = int(input())
print(find_beutiful(n))


year = int(input()) + 1
unique = False

def checkUnique(year):
	checkList = []
	for c in str(year):
		if c in checkList:
			return False
		checkList.append(c)
	return True
while True:
	if checkUnique(year) == True:
		break
	else:
		year += 1
print(year)


n = int(input())
while True:
	n = n + 1
	s = list(str(n))
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		break
print(n)


num = int(input())
num += 1
while True:
	nstr = str(num)
	q = 1
	for i in range(len(nstr)):
		if nstr[i] in nstr[:i] or nstr[i] in nstr[i + 1:]:
			q = 0
	if q == 1:
		print(num)
		break
	num += 1


numb = int(input())
numb += 1
while len(set(map(int, str(numb)))) != len(str(numb)):
	numb += 1
print(numb)


a = int(input())
for k in range(8000):
	ap = 1
	sal = 0
	a = a + 1
	b = str(a)
	b = ' '.join(b)
	b = b.split()
	for i in range(4):
		c = b[i]
		for t in range(i + 1, 4):
			if c == b[t]:
				sal = 1
				break
		if sal == 1:
			ap = 0
			break
	if ap == 1:
		break
for y in range(4):
	b[y] = str(b[y])
yonax = ''.join(b)
print(yonax)


try:
	n = int(input())
	n1 = n + 1
	while True:
		r1 = n1 // 1000
		r2 = n1 // 100 % 10
		r3 = n1 // 10 % 10
		r4 = n1 % 10
		if r1 != r2 and r2 != r3 and (r3 != r4) and (r2 != r4) and (r1 != r4) and (r1 != r3):
			break
		n1 += 1
	print(n1)
except Exception as e:
	print(e)


p = int(input())
while True:
	p += 1
	v = p // 1000 % 10
	c = p // 100 % 10
	b = p // 10 % 10
	m = p % 10
	if v != c and v != b and (v != m) and (c != b) and (c != m) and (b != m):
		break
print(p)


a = 0
y = input()
while True:
	y = str(int(y) + 1)
	for i in y:
		if y.count(i) > 1:
			break
		elif i == y[3]:
			a = 1
	if a == 1:
		break
print(y)


n = int(input())
m = [n // 1000, (n - n // 1000 * 1000) // 100, (n % 100 - n % 10) // 10, n % 10]
b = set(m)
v = n + 1
q = [v // 1000, (v - v // 1000 * 1000) // 100, (v % 100 - v % 10) // 10, v % 10]
s = set(q)
while len(s) != 4:
	v += 1
	q = [v // 1000, (v - v // 1000 * 1000) // 100, (v % 100 - v % 10) // 10, v % 10]
	s = set(q)
print(v)


year = int(input())
for i in range(year + 1, 9013):
	d1 = i % 10
	d2 = i // 10 % 10
	d3 = i // 100 % 10
	d4 = i // 1000 % 10
	if d1 != d2 and d1 != d3 and (d1 != d4) and (d2 != d3) and (d2 != d4) and (d3 != d4):
		print(i)
		break


n = int(input())
n += 1
while 1:
	s = str(n)
	lst = []
	flag = True
	for i in s:
		if i in lst:
			flag = False
		else:
			lst.append(i)
	if flag:
		print(n)
		break
	n += 1


n = int(input())
n1 = n
t = 0
while True:
	n += 1
	a = set(list(str(n)))
	t += 1
	if len(a) == 4:
		break
print(t + n1)


p = int(input()) + 1
while len(set(str(p))) < 4:
	p += 1
print(p)


n = int(input())
for i in range(n + 1, 9013):
	t = i
	a = t % 10
	t = t // 10
	b = t % 10
	t = t // 10
	c = t % 10
	t = t // 10
	d = t
	if a != b and b != c and (c != d) and (d != a) and (a != c) and (b != d):
		print(i)
		break


a = int(input())
a = a + 1
while a <= 10000:
	y = str(a)
	if y[0] != y[1]:
		s = [y[0], y[1]]
		if y[2] not in s:
			s = [y[1], y[2], y[0]]
			if y[3] not in s:
				print(a)
				break
	a = a + 1


a = str(input())
g = 1
k = int(a)
k = k + 1
a = str(k)
while g:
	k = int(a)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		g = 0
	else:
		k = k + 1
		a = str(k)
print(k)


n = int(input())
a = set()
for i in range(n + 1, 9999):
	l = i
	for _ in range(0, 4):
		k = l % 10
		l = l // 10
		a.add(k)
	if len(a) == 4:
		print(i)
		break
	a.clear()


s = str(input())
k = 0
while k != 1:
	s = int(s) + 1
	s = str(s)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		k += 1
print(s)


year = str(int(input()) + 1)
while len(set(year)) != 4:
	year = str(int(year) + 1)
print(year)


def check(n):
	a = list(str(n))
	if (a[0] != a[1]) & (a[0] != a[2]) & (a[0] != a[3]) & (a[1] != a[2]) & (a[1] != a[3]) & (a[2] != a[3]):
		return 1
	else:
		return 0
n = int(input())
while True:
	n = n + 1
	if check(n) == 1:
		break
print(n)


n = int(input())
n += 1
while True:
	k = list(str(n))
	if len(k) == len(set(k)):
		print(n)
		break
	n += 1


n = list(map(int, input().strip().split()[:4]))
p = int(''.join(map(str, n)))
s = [1, 1]
while len(set(s)) != len(s):
	p += 1
	s = list(map(int, str(p)))
print(p)


year = int(input())
for a in range(year + 1, 10000):
	a = str(a)
	m = [a[0], a[1], a[2], a[3]]
	l = set(m)
	if len(l) == 4:
		print(a)
		break


n = int(input())
n += 1
while 1:
	s = set()
	h = str(n)
	for i in h:
		s.add(i)
	if len(s) == len(h):
		print(h)
		break
	n += 1


import sys
a = int(input())
for i in range(a + 1, sys.maxsize):
	if len(set(str(i))) == 4:
		print(i)
		break
	else:
		pass


n = int(input())
for i in range(n + 1, 9999):
	x = str(i)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[3]) and (x[1] != x[2]) and (x[2] != x[3]):
		print(i)
		quit()


n = int(input())
ans = 0
while n < 10000:
	n += 1
	k = list(str(n))
	if len(set(k)) == 4:
		ans = n
		break
print(ans)


y = int(input())
i = 0
for i in range(y + 1, 9100):
	x = []
	j = i
	flag = 0
	while j > 0:
		k = j % 10
		if k in x:
			flag = 1
			break
		x.append(k)
		j = j // 10
	if flag == 0:
		break
print(i)


num = 0

def fun(n):
	global num
	r = set(map(int, str(n)))
	if len(r) == 4:
		num = n
		return True
	else:
		return False
n = int(input())
while True:
	n += 1
	if fun(n):
		break
print(num)


def nextDistinctYear(y):
	y += 1
	while True:
		if isDistinct(y):
			return y
		y += 1

def isDistinct(y):
	yl = list(map(int, str(y)))
	distinct = True
	for i in range(len(yl)):
		for j in range(len(yl)):
			if i == j:
				continue
			if yl[i] == yl[j]:
				distinct = False
	return distinct
year = int(input())
print(nextDistinctYear(year))


n = str(input())
while n:
	n = str(int(n) + 1)
	if n[0] != n[1] and n[1] != n[2] and (n[2] != n[3]) and (n[1] != n[3]) and (n[0] != n[2]) and (n[0] != n[3]):
		break
print(n)


y = int(input())
for i in range(y + 1, 10000):
	if len(set(str(i))) == len(str(i)):
		print(i)
		break


year = int(input())
nextyear = year + 1
while nextyear > year:
	if len(set(str(nextyear))) == 4:
		print(nextyear)
		break
	else:
		nextyear += 1
		continue


a = int(input())
for i in range(1, 8001):
	a += 1
	if len(set(list(str(a)))) == 4:
		print(a)
		break


n = int(input())
c = False

def distinct(n):
	s = str(n)
	c = False
	for x in range(0, len(s) - 1):
		if c == False:
			for y in range(x + 1, len(s)):
				if s[x] == s[y]:
					c = True
					break
				else:
					c = False
		else:
			break
	return c
n = n + 1
c = distinct(n)
while c == True:
	n = n + 1
	c = distinct(n)
print(n)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	y = int(input())
	for i in range(y + 1, 9013):
		l1 = []
		j = i
		while j > 0:
			l1.append(j % 10)
			j //= 10
		if len(set(l1)) == 4:
			print(i)
			break


def has_distinct_digits(x):
	l = list(str(x))
	return len(set(l)) == len(l)

def least_beautiful(x):
	while not has_distinct_digits(x + 1):
		x += 1
	return x + 1
print(least_beautiful(int(input())))


n = int(input())
n1 = str(n + 1)
setup = True
while setup:
	setup = False
	for i in n1:
		if n1.count(i) > 1:
			n1 = str(int(n1) + 1)
			setup = True
			break
print(n1)


a = int(input(''))
a = a + 1
str_number = str(a)
count = 0
while count == 0:
	if len(set(str_number)) == len(str_number):
		print(str_number)
		count = 1
	else:
		a = a + 1
		str_number = str(a)


input_year = int(input())

def distict_year(x):
	if len(set(str(x))) == len(str(x)):
		return True
	return False
input_year += 1
while distict_year(input_year) != True:
	input_year = input_year + 1
print(input_year)


def distinct(y):
	s = str(y)
	for digit in s:
		if s.count(digit) > 1:
			return False
	return True
year = int(input()) + 1
while not distinct(year):
	year = year + 1
print(year)


def check(x):
	return len(set(str(x))) == len(str(x))
y = int(input()) + 1
while check(y) is False:
	y += 1
print(y)


import sys
import math
import collections
from collections import deque
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
for _ in range(T):
	n = int(stdin.readline().strip('\n'))
	n = n + 1
	flag = True
	while flag:
		if len(str(n)) == len(set(str(n))):
			print(n)
			break
		else:
			n += 1


n = str(input())

def num(n):
	while True:
		n = str(int(n) + 1)
		if len(set(n)) == 4:
			return n
print(num(n))


for i in range(int(input()) + 1, 100000000):
	if len(set([int(j) for j in str(i)])) == 4:
		print(i)
		break


n = int(input())
for i in range(n + 1, 9020):
	l = list(dict.fromkeys(str(i)))
	if len(l) == 4:
		break
print(i)


np = input()
n = str(int(np) + 1)
k = len(n)
j = len(set(n))
c = 0
while True:
	if k == len(set(n)):
		print(int(n))
		break
	else:
		n = str(int(n) + 1)
		c = c + 1


import sys
import math
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
flag = 1
while flag:
	n += 1
	if len(list(str(n))) == len(list(set(str(n)))):
		print(n)
		flag = 0


s = int(input())
s = s + 1
while len(set(str(s))) < 4:
	s += 1
print(s)


x = int(input())
x += 1
while 1:
	s = [int(n) for n in str(x)]
	if s.count(s[0]) == 1 and s.count(s[1]) == 1 and (s.count(s[2]) == 1) and (s.count(s[3]) == 1):
		print(x)
		break
	else:
		x += 1


y = input()
flag = 1
while flag:
	y = str(int(y) + 1)
	if len(set(y)) == 4:
		flag = 0
print(y)


year = int(input())
distinct_year = year + 1
while len(set(str(distinct_year))) != len(str(distinct_year)):
	distinct_year = distinct_year + 1
print(distinct_year)


y = int(input())
for i in range(y):
	y += 1
	a = y // 1000
	b = y // 100 % 10
	c = y // 10 % 10
	d = y % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(y)


s = input()
i = int(s) + 1
s = str(i)
w = 0
while True:
	for f in range(w + 1, 4):
		if s[w] == s[f]:
			i += 1
			s = str(i)
			w = -1
			break
	w += 1
	if w == 3:
		break
print(s)


n = int(input())
while 1:
	n = n + 1
	a = n // 1000
	b = n // 100 % 10
	c = n // 10 % 10
	d = n % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(n)


n = int(input())
s = set()
for i in range(n + 1, 9013):
	z = str(i)
	for j in range(0, len(z)):
		s.add(int(z[j]))
	if len(s) == 4:
		print(z)
		break
	else:
		s.clear()


import sys
n = int(input())
s = set()
for i in range(n + 1, 9500):
	tmp = i
	for j in range(4):
		s.add(tmp % 10)
		tmp //= 10
	if len(s) == 4:
		print(i)
		exit()
	s.clear()


t = int(input())
st = str(t)
while True:
	t = t + 1
	st = str(t)
	e = set()
	for i in st:
		e.add(i)
	if len(e) == 4:
		print(t)
		break
	else:
		continue


def byear(eded):
	a = set()
	for x in str(eded):
		a.add(int(x))
	if len(a) == len(str(eded)):
		return True
n = int(input())
while True:
	n += 1
	if byear(n):
		print(n)
		break


n = int(input())
n1 = n

def works(x):
	s = set()
	for ch in str(x):
		s.add(int(ch))
	return len(s) == 4
n += 1
while not works(n):
	n += 1
print(n)


year = int(input())
out = year + 1
while out // 1000 == out // 100 % 10 or out // 1000 == out // 10 % 10 or out // 1000 == out % 10 or (out % 10 == out // 100 % 10) or (out // 10 % 10 == out // 100 % 10) or (out // 10 % 10 == out % 10):
	out += 1
print(out)


n = int(input()) + 1
while n:
	year = [int(x) for x in str(n)]
	if len(set(year)) == len(year):
		print(n)
		break
	n += 1


y = int(input())
x = y + 1
while True:
	s = str(x)
	l = list(s)
	se = set(l)
	if len(l) == len(se):
		print(x)
		break
	x += 1


num = int(input())
while 1:
	num += 1
	n = num
	d = set()
	r = 0
	while n > 0:
		d.add(n % 10)
		n = n // 10
		r += 1
	if r == len(d):
		print(num)
		break


lucky_year = set()
a = []
y = int(input())
for i in range(1000, 10000):
	god = list(map(int, str(int(i))))
	for j in god:
		lucky_year.add(j)
	if len(lucky_year) == 4:
		a.append(i)
	lucky_year.clear()
for i in a:
	if y < i:
		print(i)
		break


x = input()
y = int(x) + 1

def k(i):
	return str(y).count(str(y)[i])
while k(0) + k(1) + k(2) + k(3) != 4:
	y += 1
print(y)


def main():
	year = input()
	print(next_unique_year(year, int(year)))

def next_unique_year(year, next_year):
	next_year = str(next_year)
	storage = []
	for i in range(4):
		if next_year[i] in storage:
			return next_unique_year(year, int(next_year) + 1)
			break
		else:
			storage.append(next_year[i])
	if int(next_year) > int(year):
		return int(next_year)
	elif int(next_year) < int(year):
		return next_unique_year(year, int(next_year) + 1)
	else:
		return next_unique_year(year, int(next_year) + 1)
main()


import math
import sys

def isLucky(n):
	ar = [False] * 10
	while n > 0:
		digit = math.floor(n % 10)
		if ar[digit]:
			return False
		ar[digit] = True
		n = n // 10
	return True
t = int(input())
for i in range(t + 1, sys.maxsize):
	if isLucky(i):
		print(i)
		break
	else:
		continue


n = int(input())
while 1:
	n += 1
	no = n
	l = []
	while no > 0:
		rem = no % 10
		l.append(rem)
		no = no // 10
	flag = 1
	for i in range(4):
		for j in range(4):
			if i != j:
				if l[i] == l[j]:
					flag = 0
					break
		if flag == 0:
			break
	if flag == 1:
		break
if flag:
	print(n)


n = int(input())
i = n + 1
while i > n:
	st = str(i)
	if len(set(st)) == 4:
		print(i)
		break
	i += 1


__author__ = 'runekri3'
cur_year = int(input())
while 1:
	cur_year += 1
	if len(set(str(cur_year))) == 4:
		break
print(cur_year)


n = int(input())
while 1 == 1:
	l = str(n + 1)
	n = n + 1
	s = set(l)
	if len(s) == 4:
		print(n)
		break


n = int(input())
for i in range(0, 9000):
	n = n + 1
	m = str(n)
	if m[0] != m[1] and m[0] != m[2] and (m[0] != m[3]) and (m[1] != m[2]) and (m[1] != m[3]) and (m[2] != m[3]):
		print(m)
		break


main_year = int(input())
origin_year = 0
year_list = []
while origin_year != 4:
	main_year = main_year + 1
	year_list.clear()
	for el in str(main_year):
		year_list.append(el)
	if len(set(year_list)) == 4:
		origin_year = 4
print(main_year)


s = input()
for x in range(int(s) + 1, 123456789):
	if len(str(x)) == len({a for a in str(x)}):
		print(x)
		break


n = int(input())
for year in range(n + 1, 9013, 1):
	s = set(str(year))
	if len(s) == 4:
		print(year)
		break


k = input()
find = 0
while find < 1:
	k = str(int(k) + 1)
	if len(set(k)) == 4:
		find = 1
if find >= 1:
	print(int(k))


a = eval(input())
a1 = 0
while a1 == 0:
	a = a + 1
	c = list(set(str(a)))
	if len(c) == 4:
		print(a)
		a1 = 1


n = int(input())
f = 0
i = n + 1
while f == 0:
	a = i // 1000
	b = i // 100 % 10
	c = i // 10 % 10
	d = i % 10
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		i = i + 1
		continue
	else:
		f = 1
		print(i)


n = int(input())
while True:
	n += 1
	s = ''
	for i in range(len(str(n))):
		if str(n)[i] not in s:
			s = s + str(n)[i]
	if int(s) == n:
		print(n)
		break


year = int(input())
flag = False
while not flag:
	year += 1
	if len(set(str(year))) == len(str(year)):
		print(year)
		exit()


year = int(input())
year1 = str(year)
year += 1
for i in range(year):
	if len(set(list(str(year)))) == 4:
		print(year)
		break
	else:
		year += 1


y = int(input())
for i in range(y + 1, y + 1000):
	y = y + 1
	z = str(y)
	x = list(z)
	a = set(x)
	if len(x) == len(a):
		print(y)
		exit()
	else:
		pass


year = int(input())
start = year + 1
check = True
while check:
	if len(set(str(start))) == 4:
		print(start)
		break
	else:
		start += 1


year = int(input())
year += 1
while True:
	s = set()
	num = year
	while num > 0:
		s.add(num % 10)
		num //= 10
	if len(s) == 4:
		break
	year += 1
print(year)


year = int(input())

def check(year):
	for n in range(len(str(year))):
		if str(year).count(str(year)[n]) > 1:
			return False
			n = len(year + 1)
year_new = year + 1
while check(year_new) == False:
	year_new += 1
print(year_new)


year = int(input())
year += 1
while True:
	y = 0
	a = []
	for digit in str(year):
		a.append(int(digit))
	for x in a:
		y += a.count(x)
	if y == 4:
		print(year)
		break
	else:
		year += 1


n = int(input())
s = n + 1
while True:
	c = ''
	u = 0
	for i in str(s):
		if i not in c:
			c += i
	if c == str(s):
		print(s)
		break
	s += 1


n = int(input())
while 1:
	n += 1
	s = str(n)
	d = {}
	for i in s:
		d[i] = 1
	if len(d) == len(s):
		print(s)
		break


n = int(input())
m = n
r = 0
h = []
while True:
	m += 1
	h = list(str(m))
	h.sort()
	r = 1
	for i in range(0, 3):
		if h[i] == h[i + 1]:
			r = 0
			break
	if r == 1:
		print(m)
		break


def hasDoubleNumber(number, length):
	for i in range(len(year_string)):
		if year_string[i] in year_string[i + 1:len(year_string)]:
			return True
	return False
year = int(input())
year += 1
isCorrect = False
while isCorrect == False:
	year_string = str(year)
	if hasDoubleNumber(year_string, len(year_string)) == True:
		year += 1
		isCorrect = False
	else:
		print(year)
		isCorrect = True


n = int(input())
f = False
y = n
while f != True:
	y += 1
	a = y // 1000
	b = y // 100 % 10
	c = y // 10 % 10
	d = y % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		f = True
print(y)


def BeautifulYear(y):
	di = {}
	for i in y:
		di[i] = di.get(i, 0) + 1
		if di[i] > 1:
			return False
	return True
s = input()
beauty = False
while not beauty:
	s = str(int(s) + 1)
	beauty = BeautifulYear(s)
print(s)


n = int(input())
next = n
i = 1
while 1:
	prev = set(str(next + i))
	if len(prev) == len(str(next)):
		print(next + i)
		break
	else:
		i += 1


year = int(input())
while 1:
	year += 1
	str_year = str(year)
	if len(set(str_year)) == len(str(year)):
		print(year)
		break


def check_equality():
	if a not in [b, c, d] and b not in [c, d] and (c != d):
		print(int(''.join((str(i) for i in [a, b, c, d]))))
		exit()
digit = str(int(input()) + 1)
(a, b, c, d) = [int(x) for x in digit]
for a in range(a, 10):
	check_equality()
	for b in range(b, 10):
		check_equality()
		for c in range(c, 10):
			check_equality()
			for d in range(d, 10):
				check_equality()
			d = 0
		c = 0
	b = 0


t = int(input())
q = 1
while q != 0:
	g = 0
	t = t + 1
	q = str(t)
	l = len(q)
	for i in range(0, 10):
		if str(i) in q:
			g = g + 1
	if g == l:
		print(q)
		q = 0
		break


def sat(a):
	a = str(a)
	a = list(a)
	l = len(a)
	s = set(a)
	return l == len(s)
y = int(input()) + 1
i = 1
while not sat(y):
	y = y + 1
	i += 1
print(y)


_ = int(input())
_ += 1
while True:
	if len(str(_)) == len(set(str(_))):
		print(_)
		break
	else:
		_ += 1


x = input()
y = x
while y == x or (x[0] == x[1] or x[0] == x[2] or x[0] == x[3] or (x[1] == x[2]) or (x[1] == x[3]) or (x[2] == x[3])):
	x = int(x) + 1
	x = str(x)
print(x)


year = int(input()) + 1
Set = set(str(year))
while len(Set) != 4:
	year = str(int(year) + 1)
	Set = set(year)
else:
	print(year)


n = int(input())
c = 0
n += 1
while True:
	k = str(n)
	if len(set(k)) == len(k):
		print(n)
		break
	n += 1


def main():
	number = int(input())
	while number < 9876:
		number += 1
		text = str(number)
		if text[0] != text[1] and text[0] != text[2] and (text[0] != text[3]) and (text[1] != text[2]) and (text[1] != text[3]) and (text[2] != text[3]):
			print(number)
			break
main()


year = int(input())
while True:
	year += 1
	sy = set(list(str(year)))
	if len(sy) == 4:
		break
print(year)


s = int(input())
for i in range(s, 100000):
	if len(set(str(i))) == 4 and i > s:
		print(i)
		break


n = input()

def ch(x):
	x = str(x)
	c = 0
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		c = 1
	return c
m = int(n) + 1
while ch(m) == 0:
	m += 1
print(m)


s = input()
n = int(s)
for i in range(n + 1, 10000):
	x = str(i)
	p = len(set(x))
	k = len(x)
	if k == p:
		y = i
		break
print(y)


s = int(input()) + 1
while True:
	s = str(s)
	s1 = set(list(s))
	if len(s) == len(s1):
		print(s)
		break
	else:
		s = int(s) + 1


def unique_digits(number):
	visited_numbers = [0 for i in range(10)]
	digits = list(str(number))
	for num in digits:
		num = int(num)
		if visited_numbers[num] == 1:
			return False
		else:
			visited_numbers[num] += 1
	return True
year_number = int(input())
while True:
	year_number += 1
	if unique_digits(year_number):
		break
print(year_number)


y = int(input())
l = y + 1
next_year = str(l)
while True:
	(a, b, c, d) = list(next_year)
	if a == b or b == c or c == d or (a == d) or (a == c) or (b == d):
		k = int(next_year)
		k += 1
		next_year = str(k)
	else:
		print(next_year)
		break


def main():
	y = int(input())
	digits = [str(i) for i in range(10)]
	while True:
		y += 1
		if len([i for i in digits if i not in list(str(y))]) == 6:
			break
	print(y)
main()


y = int(input())
for ye in range(y + 1, 10000):
	byear = 0
	year = str(ye)
	for i in year:
		if year.count(i) == 1:
			byear = byear + 1
	if byear == 4:
		print(ye)
		break


num = input()
num = int(num) + 1

def isdistinct(n):
	n = str(n)
	set_of_numbers = []
	for k in range(0, 10):
		set_of_numbers.append(0)
	for i in n:
		if set_of_numbers[int(i)] == 1:
			return False
		else:
			set_of_numbers[int(i)] = 1
	return True
while num < 9999:
	if isdistinct(num) == True:
		print(str(num))
		break
	num = int(num) + 1


n = str(input())
y = int(n)
list1 = []
list2 = []
for char in n:
	list1.append(char)
while True:
	y += 1
	n1 = str(y)
	for char1 in n1:
		list2.append(char1)
	if list2[0] != list2[1] and list2[1] != list2[2] and (list2[2] != list2[3]) and (list2[0] != list2[2]) and (list2[0] != list2[3]) and (list2[1] != list2[3]):
		print(y)
		break
	else:
		list2.clear()
		continue


year = int(input())
year += 1
while year < 9999:
	s = str(year)
	if len(set(s)) == 4:
		print(year)
		break
	year += 1


import math

def bad(n):
	s = list(str(n))
	s.sort()
	i = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			return 1
		i += 1
	return 0
n = int(input()) + 1
while bad(n):
	n += 1
print(n)


y = int(input())
while y:
	y += 1
	sy = str(y)
	if len(set(sy)) == 4:
		print(y)
		break


a = input()
a = str(int(a) + 1)
while a.count(a[0]) > 1 or a.count(a[1]) > 1 or a.count(a[2]) > 1:
	a = str(int(a) + 1)
print(a)


y = int(input())
while True:
	y += 1
	if str(y) == ''.join(list(dict.fromkeys(str(y)))):
		print(y)
		break


try:
	num = int(input())
	num += 1
	s = str(num)
	count = 1
	while count != -4:
		count = 0
		for i in range(4):
			if s[i] in s[i + 1:]:
				num += 1
				count += 1
				s = str(num)
			else:
				count -= 1
	print(s)
except:
	pass


a = int(input())
a = a + 1
while a // 1000 == a % 10 or a // 1000 == a // 100 % 10 or a // 1000 == a // 10 % 10 or (a // 100 % 10 == a // 10 % 10) or (a // 100 % 10 == a % 10) or (a // 10 % 10 == a % 10):
	a = a + 1
else:
	print(a)


q = int(input())

def isdif(numb):
	flag = 0
	aux = [0] * 10
	numb_aux = str(numb)
	for i in range(len(numb_aux)):
		aux[int(numb_aux[i])] += 1
	for k in range(0, 10):
		if aux[k] > 1:
			flag = 1
			break
	if flag == 0:
		return 1
	else:
		return -1
while 42:
	q += 1
	if isdif(q) == 1:
		print(q)
		break


def razn(n):
	while True:
		n = n + 1
		if len(set(str(n))) == 4:
			print(n)
			break
a = int(input())
razn(a)


import math
inp = lambda : (int, input().split())
n = int(input())
res = 0
n += 1
while len(set(str(n))) < 4:
	n += 1
print(n)


a = int(input())
(i, b) = (0, a)
while i < 1:
	b += 1
	c = set(str(b))
	if len(c) == len(str(b)):
		print(b)
		i += 1


a = input()
n = int(a)
while True:
	n += 1
	s = str(n)
	i = 0
	j = i + 1
	flag = True
	while i < 3 and flag:
		while j < 4:
			if s[i] == s[j]:
				flag = False
				break
			else:
				j += 1
		i += 1
		j = i + 1
	if flag:
		break
print(n)


y1 = str(int(input()) + 1)
while y1:
	if len(y1) == len(set(y1)):
		print(y1)
		break
	else:
		y1 = int(y1)
		y1 += 1
		y1 = str(y1)


year = int(input())
year_len = 0
while year_len != 4:
	year += 1
	year_len = len(set(str(year)))
print(year)


new_year = int(input())
while new_year > 0:
	new_year += 1
	x = str(new_year)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		break
	else:
		continue
print(new_year)


def beauty(y):
	s = 0
	for i in ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']:
		if y.count(i) >= 2:
			s += 1
	if s == 0:
		return 1
	else:
		return 0
year = input()
s = int(year)
if beauty(year) == 0:
	while beauty(year) == 0:
		s += 1
		year = str(s)
	print(s)
else:
	while beauty(year) == 1:
		s += 1
		year = str(s)
		break
	while beauty(year) == 0:
		s += 1
		year = str(s)
	print(s)


n = int(input())
while 1:
	n += 1
	a = n
	b = {}
	while a > 0:
		c = a % 10
		a = a // 10
		b[c] = 1
	if len(b) == 4:
		print(n)
		break


n = int(input())
for i in range(n + 1, 9013):
	ns = list(str(i))
	if len(set(ns)) == len(ns):
		print(i)
		break


(n, check) = (int(input()), False)
year = n + 1
while True:
	for i in [i for i in str(year)]:
		if str(year).count(i) >= 2:
			check = True
			break
	if not check:
		print(year)
		break
	(check, year) = (False, year + 1)


n = int(input())
while True:
	n += 1
	s = str(n)
	se = set(s)
	if len(se) == len(s):
		print(n)
		break


n = int(input())
lst = []
n += 1
work = True
while work:
	a = str(n)
	lst = list(a)
	if a[0] == a[1] or a[0] == a[2] or a[0] == a[3] or (a[1] == a[0]) or (a[1] == a[2]) or (a[1] == a[3]) or (a[2] == a[0]) or (a[2] == a[1]) or (a[2] == a[3]) or (a[3] == a[0]) or (a[3] == a[1]) or (a[3] == a[2]):
		n += 1
	else:
		work = False
		print(n)


a = int(input())
b = a
d = []
t = True
while t:
	b += 1
	c = str(b)
	for i in c:
		if i not in d:
			d.append(i)
	if len(d) == 4 and b > a:
		t = False
	else:
		d = []
print(b)


n = int(input()) + 1

def checkYear(year):
	for i in range(4):
		for j in range(4):
			if str(year)[i] == str(year)[j] and i != j:
				return False
	return True
while not checkYear(n):
	n += 1
print(str(n))


x = input()
lista = []
x = str(int(x) + 1)
while True:
	if len(lista) == 4:
		print(''.join(lista))
		break
	if len(lista) != 4:
		lista = []
	for i in range(4):
		if x[i] not in lista:
			lista.append(x[i])
	x = str(int(x) + 1)


k = int(input()) + 1
while k:
	if len(set(str(k))) == len(str(k)):
		print(k)
		break
	k += 1


year = int(input())
size = 0
while size < 4:
	year = year + 1
	y = str(year)
	l = list(y)
	set1 = set(l)
	size = len(set1)
print(year)


s = input()
num = int(s)

def check_unique(s):
	digits = {x for x in s}
	return True if len(digits) == 4 else False
for i in range(num + 1, 9013):
	if check_unique(str(i)):
		print(i)
		break


n = int(input())
while True:
	n = n + 1
	s = str(n)
	t = len(dict.fromkeys(s))
	if t == len(s):
		print(s)
		break


n1 = int(input()) + 1
n2 = list(map(int, str(n1)))
while len(set(n2)) != 4:
	n1 += 1
	n2 = list(map(int, str(n1)))
print(n1)


y = int(input().strip()) + 1

def isValid(y):
	occ = set()
	for c in y:
		if c in occ:
			return False
		else:
			occ.add(c)
	return True
while not isValid(str(y)):
	y += 1
print(y)


n = input()
arr = []
a = int(n) + 1
while a < 9013:
	x = map(int, str(a))
	for values in x:
		if values not in arr:
			arr.append(values)
	if len(arr) == 4:
		print(a)
		break
	else:
		arr = []
		a = a + 1


a = int(input())
s = 1
while s != 0:
	s = 0
	a = a + 1
	b = str(a)
	c = []
	for j in range(len(b)):
		c.append(b[j])
	c.sort()
	for i in range(len(c) - 1):
		if c[i] == c[i + 1]:
			s = s + 1
print(a)


ans = []
a = int(input())
for b in range(a + 1, 9999):
	if b % 10 != b // 10 % 10 and b % 10 != b // 100 % 10 and (b % 10 != b // 1000) and (b // 10 % 10 != b // 100 % 10) and (b // 100 % 10 != b // 1000) and (b // 1000 != b // 10 % 10):
		ans.append(b)
print(min(ans))


import sys
inp = sys.stdin
y = int(inp.readline()) + 1

def check_dif(num):
	s = str(num)
	ok = 1
	for i in range(len(s)):
		if s[i] in s[i + 1:]:
			ok = 0
	return ok
while check_dif(y) == 0:
	y += 1
print(y)


number = int(input()) + 1
while len(set(str(number))) != 4:
	number += 1
print(number)


for i in range(int(input()) + 1, 10000):
	j = list(str(i))
	if len(j) == len(set(j)):
		print(i)
		break


import sys
x = input()
x = int(x) + 1
for i in range(1000, 9012):
	list1 = [int(x % 10), int(x / 10 % 10), int(x / 100 % 10), int(x / 1000 % 10)]
	flag = 0
	for j in range(0, len(list1)):
		for k in range(j + 1, len(list1)):
			if list1[j] == list1[k]:
				flag = 1
	if flag == 1:
		x += 1
	else:
		print(x)
		sys.exit()


year = str(int(input()) + 1)
while True:
	check_year = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in year:
		check_year[int(i)] = 1
	if sum(check_year) < 4:
		year = str(int(year) + 1)
	else:
		print(year)
		break


def nice(year):
	return len(set(year)) == len(year)
year = int(input()) + 1
while not nice(str(year)):
	year += 1
print(year)


s = str(input())
t = int(s)
while True:
	t = t + 1
	j = str(t)
	set_j = set()
	for item in j:
		set_j.add(item)
	if len(set_j) == 4:
		print(j)
		break


n = int(input())
while True:
	n += 1
	if len(set(str(n))) == 4:
		print(n)
		exit(0)


n = int(input())
i = n + 1
while 1:
	f = i
	d = {}
	d[f % 10] = 1
	f = f // 10
	if f % 10 in d:
		i += 1
		continue
	d[f % 10] = 1
	f = f // 10
	if f % 10 in d:
		i += 1
		continue
	d[f % 10] = 1
	f = f // 10
	if f in d:
		i += 1
		continue
	print(i)
	break


def check(x):
	(a, b) = (0, 0)
	i = 1
	s = 0
	r = []
	hell = 1
	while x > 9:
		b = x % (10 * i) / i
		x = x - b * i
		r.append(b)
		i = i * 10
	r.sort()
	for i in range(len(r) - 1):
		if r[i + 1] == r[i]:
			hell = 0
	return hell
year = int(input(''))
p = 0
while p != 1:
	year += 1
	p = check(year)
print(year)


year = int(input())
while True:
	lis = []
	year += 1
	n = str(year)
	for i in range(3):
		c = n.count(n[i])
		lis.append(c)
	if 2 in lis or 3 in lis or 4 in lis:
		continue
	print(year)
	break


year = input()
n = True
while n:
	year = int(year) + 1
	year = str(year)
	if not (((year[0] == year[1] or year[0] == year[2] or year[0] == year[3]) or (year[1] == year[2] or year[1] == year[3])) or year[2] == year[3]):
		n_year = year
		n = False
print(n_year)


q = int(input())
q += 1
n = q
a = n % 10
n = n // 10
b = n % 10
n = n // 10
c = n % 10
n = n // 10
d = n % 10
while d == a or d == b or d == c or (a == b) or (a == c) or (b == c):
	q += 1
	n = q
	a = n % 10
	n = n // 10
	b = n % 10
	n = n // 10
	c = n % 10
	n = n // 10
	d = n % 10
print(q)


for i in range(int(input()) + 1, 1000000):
	k = True
	for j in str(i):
		if str(i).count(j) != 1:
			k = False
			break
	if k == True:
		print(i)
		break


x = input()
n = int(x)
condition = False
while not condition:
	n += 1
	condition = True
	l = list(str(n))
	for i in range(len(l)):
		if l.count(l[i]) != 1:
			condition = False
			break
print(n)


year = int(input())
while True:
	year += 1
	number = year
	last_digit = number % 10
	number = number // 10
	third_digit = number % 10
	number = number // 10
	second_digit = number % 10
	number = number // 10
	first_digit = number % 10
	if first_digit != second_digit and first_digit != third_digit and (first_digit != last_digit):
		if second_digit != third_digit and second_digit != last_digit:
			if third_digit != last_digit:
				print(year)
				break


year = int(input()) + 1
st = str(year)

def unique():
	return st[0] != st[1] and st[0] != st[2] and (st[0] != st[3]) and (st[1] != st[2]) and (st[1] != st[3]) and (st[2] != st[3])
while not unique():
	year += 1
	st = str(year)
print(year)


y = int(input())
while True:
	y += 1
	if len(set([c for c in str(y)])) == 4:
		print(y)
		break


def main():
	n = int(input())
	dist = False
	while not dist:
		n += 1
		nstr = str(n)
		nstr_set = set(nstr)
		if len(nstr) == len(nstr_set):
			dist = True
	print(n)
main()


n = int(input())
n = n + 1
while n > 1000:
	n = str(n)
	n = list(n)
	if len(n) == len(set(n)):
		break
	else:
		n = ''.join(n)
		n = int(n)
		n = n + 1
n = ''.join(n)
n = int(n)
print(n)


year = int(input()) + 1
while True:
	for char in str(year):
		if str(year).count(char) > 1:
			break
	else:
		break
	year += 1
print(year)


def is_unique(num):
	di = {}
	for i in num:
		di[i] = 1
	if len(di) == 4:
		return True
	else:
		return False
year = int(input())
year += 1
done = False
while done != True:
	if is_unique(str(year)):
		print(year)
		break
	else:
		year += 1


def distinct(n):
	a = [0] * 10
	while n != 0:
		t = n % 10
		n = int(n / 10)
		a[t] += 1
		if a[t] > 1:
			return False
	return True

def nextYear(n):
	i = n + 1
	while not distinct(i):
		i += 1
	return i
print(nextYear(int(input())))


n = int(input())
n += 1
a = set(str(n))
l = len(a)
while l != 4:
	n += 1
	l = len(set(str(n)))
print(n)


y = int(input())
searched_number = y + 1
str_s_n = str(searched_number)
list_s_n = list(map(int, str_s_n))
while len(list_s_n) != len(set(list_s_n)):
	searched_number += 1
	str_s_n = str(searched_number)
	list_s_n = list(map(int, str_s_n))
print(searched_number)


import sys

def different_numbers(year):
	numbers = []
	while year:
		numbers.append(year % 10)
		year //= 10
	numbers_set = {x for x in numbers}
	return len(numbers_set) == len(numbers)
year_start = int(sys.stdin.readline()) + 1
while not different_numbers(year_start):
	year_start += 1
print(year_start)


import sys
y = int(sys.stdin.readline().split()[0])
y += 1
while y > 0:
	t = dict.fromkeys(str(y))
	if len(t) == 4:
		print(''.join(t))
		sys.exit()
	y += 1


def repetition(number):
	i = 3
	flag = 0
	repeat = []
	number = str(number)
	while i > -1:
		for j in range(i):
			if number[i] == number[j]:
				return True
		i -= 1
	return False
n = int(input())
answer = n + 1
while True:
	if repetition(answer):
		answer += 1
	else:
		break
print(answer)


y = int(input())
i = y
while i:
	i = i + 1
	j = i
	l = []
	while j > 0:
		a = j % 10
		if a not in l:
			l.append(a)
			j = j // 10
		else:
			break
	if j == 0:
		print(i)
		break


m = int(input()) + 1
while len(set(str(m))) < 4:
	m = m + 1
print(m)


year = int(input())

def check(n):
	s = set([])
	for c in str(n):
		if c in s:
			return False
		s.add(c)
	return True
year += 1
while not check(year):
	year += 1
print(year)


read = lambda : map(int, input().split())
n = int(input())
for i in range(n + 1, 10000):
	s = str(i)
	flag = 1
	for j in range(3):
		for k in range(j + 1, 4):
			if s[j] == s[k]:
				flag = 0
	if flag:
		print(i)
		break


y = int(input())
ans = 0

def distinct(n):
	n = str(n)
	l = []
	for i in n:
		l.append(int(i))
	unique = []
	for i in l:
		if i not in unique:
			unique.append(i)
	if len(unique) == 4:
		return True
	else:
		return False
while ans == 0:
	y = y + 1
	if distinct(y):
		ans = y
		print(ans)
	else:
		ans = 0


n = int(input())
c = 0
while c == 0:
	n += 1
	s = str(n)
	ss = set(s)
	if len(s) == len(ss):
		c = 1
print(n)


a = int(input())
p = a + 1
while len(list(set(str(p)))) != len(str(p)):
	p = str(int(p) + 1)
print(int(p))


x = []
for i in range(1000, 10001):
	if len(set(str(i))) == len(str(i)):
		x.append(i)
n = int(input())
for i in x:
	if i > n:
		print(i)
		break


n = int(input())
f = 0
while f == 0:
	n = n + 1
	if len(set(str(n))) == 4:
		f = 1
print(n)


y = str(input())
for x in range(int(y) + 1, 9013):
	new_str = ''
	non_str = ''
	for i in str(x):
		if i not in new_str:
			new_str += i
		else:
			non_str += i
	if len(non_str) == 0:
		print(new_str)
		break


s = int(input())
i = 0
for i in range(s + 1, 9124):
	l = list(map(int, list(str(i))))
	if len(set(l)) == 4:
		print(i)
		break


def check(n):
	n = [str(x) for x in str(n)]
	if len(n) == len(set(n)):
		return True
	return False
n = int(input())
flag = False
while flag != True:
	n += 1
	flag = check(n)
print(n)


y = int(input())
for u in range(y + 1, 10001):
	s = str(u)
	if len(set(s)) == 4:
		print(u)
		exit(0)


p = 1
i = input()
j = int(i) + 1
while p:
	flag = 0
	k = list(map(int, str(j)))
	for m in k:
		if k.count(m) > 1:
			flag += 1
			break
	else:
		if flag == 0:
			print(j)
			p = 0
	j += 1


y = int(input())
while True:
	y += 1
	s = str(y)
	if s[1:].find(s[0]) >= 0:
		continue
	elif (s[0] + s[2:]).find(s[1]) >= 0:
		continue
	elif (s[:2] + s[3:]).find(s[2]) >= 0:
		continue
	elif s[:3].find(s[3]) >= 0:
		continue
	else:
		print(y)
		break


n = int(input())
for i in range(n + 1, 10000):
	for c in str(i):
		if str(i).count(c) > 1:
			break
	else:
		print(i)
		break


n = int(input())
for i in range(n + 1, 10000):
	numb = set()
	real = i
	while i > 0:
		send = i % 10
		i = int(i / 10)
		numb.add(send)
	if len(numb) == 4:
		print(real)
		break


y = int(input())
y = y + 1
list1 = list()
while True:
	n = y
	f = 0
	while n > 0:
		d = int(n % 10)
		if d not in list1:
			list1.append(d)
		else:
			f = 1
			break
		n = int(n / 10)
	if f == 0:
		break
	list1.clear()
	y = y + 1
print(y)


x = int(input())
m = x + 1
q = 0
w = 0
e = 0
r = 0
while m < 9013:
	q = int(m / 1000)
	w = int((m - q * 1000) / 100)
	e = int((m - q * 1000 - w * 100) / 10)
	r = int(m - q * 1000 - w * 100 - e * 10)
	if q == w or q == e or q == r or (w == e) or (w == r) or (e == r):
		m = m + 1
	else:
		print(m)
		break


year_input = input()
year = int(year_input)
while True:
	year += 1
	result = str(year)
	result_set = set(result)
	if len(result) == len(result_set):
		print(result)
		break


def year(x):
	while True:
		x = str(int(x) + 1)
		if len(set(x)) == 4:
			return x
x = eval(input())
print(year(x))


input_list = []
num = 0
while True:
	if num == 1:
		break
	line = input()
	num += 1

def distinct(n):
	dlist = []
	line_list = [int(i) for i in str(n)]
	for i in line_list:
		if i not in dlist:
			dlist.append(i)
		else:
			return False
	return True
count = int(line) + 1
while not distinct(count):
	count += 1
print(count)


def sameDigit(n):
	freq = [0] * 10
	n = str(n)
	for i in n:
		if freq[int(i)] == 1:
			return False
		freq[int(i)] += 1
	return True
n = int(input())
x = False
while not x:
	n += 1
	x = sameDigit(n)
print(n)


st = input()
while True:
	i = int(st) + 1
	st = str(i)
	li = {i for i in st}
	if len(li) == len(st):
		print(st)
		break


y = int(input())
i = True
a = 0
while i:
	y = int(y)
	y += 1
	y = str(y)
	if y[0] == y[1] or y[0] == y[2] or y[0] == y[3]:
		i = True
	elif y[1] == y[0] or y[1] == y[2] or y[1] == y[3]:
		i = True
	elif y[2] == y[0] or y[2] == y[1] or y[2] == y[3]:
		i = True
	elif y[3] == y[0] or y[3] == y[1] or y[3] == y[2]:
		i = True
	else:
		y = int(y)
		break
print(y)


n = input()
flag = False
x = int(n) + 1
while not flag:
	y = str(x)
	q = set()
	for i in range(len(y)):
		q.add(y[i])
	if len(q) == len(y):
		flag = True
	x = x + 1
print(x - 1)


def getNewyear(oyear):
	o = oyear + 1
	while True:
		a = len(set(str(o)))
		if a == 4:
			print(o)
			return
		o += 1
oyear = int(input())
getNewyear(oyear)


year = int(input())
while True:
	year += 1
	y = str(year)
	for c in y:
		if y.count(c) > 1:
			break
	else:
		break
	continue
print(year)


def distinct(num):
	for c in num:
		if num.count(c) > 1:
			return False
	return True
n = int(input())
if n == 1987:
	print(2013)
else:
	for i in range(n + 1, 10000):
		if distinct(str(i)):
			print(i)
			break


a = input()
b = a
while len(sorted(b)) > len(sorted(set(str(int(a) + 1)))):
	a = str(int(a) + 1)
print(str(int(a) + 1))


y = int(input())
c = 0
while c == 0:
	c = 1
	y += 1
	t = y
	l = []
	for i in range(4):
		l.insert(i, t % 10)
		t = t // 10
	for i in range(4):
		for j in range(i + 1, 4, 1):
			if l[i] == l[j]:
				c = 0
print(y)


def checkYear(arr):
	for i in range(4):
		for j in range(i + 1, 4):
			if arr[i] == arr[j]:
				return 0
	return 1
year = int(input()) + 1
while True:
	if checkYear(str(year)):
		print(year)
		break
	year += 1


n = [i for i in str(int(input()) + 1)]
while len(set(n)) < 4:
	n = [i for i in str(int(''.join(n)) + 1)]
print(''.join(n))


def check_yr(yr):
	yr += 1
	while True:
		yr = str(yr)
		yr_set = set(yr)
		if len(yr) == len(yr_set):
			return yr
		yr = int(yr)
		yr += 1
given_yr = int(input())
print(check_yr(given_yr))


x = int(input())
i = x + 1
while True:
	if len(set(str(i))) == 4:
		print(i)
		break
	i += 1


a = input()
l = int(a)
l += 1
a = str(l)
while 1:
	b = [0] * 10
	i1 = 1
	for i in a:
		b[int(i)] += 1
		if b[int(i)] > 1:
			i1 = 0
			break
	if i1:
		print(l)
		break
	l += 1
	a = str(l)


n = int(input())
out = n + 1

def func(m):
	c = 1
	for i in str(m):
		if i in str(m)[c:]:
			m += 1
			return func(m)
		elif c != 4:
			c += 1
	return print(m)
func(out)


def check_str(s):
	dct = {}
	for x in s:
		if x in dct:
			dct[x] += 1
		else:
			dct[x] = 1
	for v in dct.values():
		if v > 1:
			return False
	else:
		return True
n = int(input()) + 1
is_found = False
while not is_found:
	if check_str(str(n)):
		is_found = True
	else:
		n += 1
print(n)


n = input()
k = str(int(n) + 1)
while len(set(k)) != 4:
	k = str(int(k) + 1)
print(k)


INPUT_YEAR = int(input())
YEAR_LIST = [1023, 1024, 1025, 1026, 1027, 1028, 1029, 1032, 1034, 1035, 1036, 1037, 1038, 1039, 1042, 1043, 1045, 1046, 1047, 1048, 1049, 1052, 1053, 1054, 1056, 1057, 1058, 1059, 1062, 1063, 1064, 1065, 1067, 1068, 1069, 1072, 1073, 1074, 1075, 1076, 1078, 1079, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1230, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1243, 1245, 1246, 1247, 1248, 1249, 1250, 1253, 1254, 1256, 1257, 1258, 1259, 1260, 1263, 1264, 1265, 1267, 1268, 1269, 1270, 1273, 1274, 1275, 1276, 1278, 1279, 1280, 1283, 1284, 1285, 1286, 1287, 1289, 1290, 1293, 1294, 1295, 1296, 1297, 1298, 1302, 1304, 1305, 1306, 1307, 1308, 1309, 1320, 1324, 1325, 1326, 1327, 1328, 1329, 1340, 1342, 1345, 1346, 1347, 1348, 1349, 1350, 1352, 1354, 1356, 1357, 1358, 1359, 1360, 1362, 1364, 1365, 1367, 1368, 1369, 1370, 1372, 1374, 1375, 1376, 1378, 1379, 1380, 1382, 1384, 1385, 1386, 1387, 1389, 1390, 1392, 1394, 1395, 1396, 1397, 1398, 1402, 1403, 1405, 1406, 1407, 1408, 1409, 1420, 1423, 1425, 1426, 1427, 1428, 1429, 1430, 1432, 1435, 1436, 1437, 1438, 1439, 1450, 1452, 1453, 1456, 1457, 1458, 1459, 1460, 1462, 1463, 1465, 1467, 1468, 1469, 1470, 1472, 1473, 1475, 1476, 1478, 1479, 1480, 1482, 1483, 1485, 1486, 1487, 1489, 1490, 1492, 1493, 1495, 1496, 1497, 1498, 1502, 1503, 1504, 1506, 1507, 1508, 1509, 1520, 1523, 1524, 1526, 1527, 1528, 1529, 1530, 1532, 1534, 1536, 1537, 1538, 1539, 1540, 1542, 1543, 1546, 1547, 1548, 1549, 1560, 1562, 1563, 1564, 1567, 1568, 1569, 1570, 1572, 1573, 1574, 1576, 1578, 1579, 1580, 1582, 1583, 1584, 1586, 1587, 1589, 1590, 1592, 1593, 1594, 1596, 1597, 1598, 1602, 1603, 1604, 1605, 1607, 1608, 1609, 1620, 1623, 1624, 1625, 1627, 1628, 1629, 1630, 1632, 1634, 1635, 1637, 1638, 1639, 1640, 1642, 1643, 1645, 1647, 1648, 1649, 1650, 1652, 1653, 1654, 1657, 1658, 1659, 1670, 1672, 1673, 1674, 1675, 1678, 1679, 1680, 1682, 1683, 1684, 1685, 1687, 1689, 1690, 1692, 1693, 1694, 1695, 1697, 1698, 1702, 1703, 1704, 1705, 1706, 1708, 1709, 1720, 1723, 1724, 1725, 1726, 1728, 1729, 1730, 1732, 1734, 1735, 1736, 1738, 1739, 1740, 1742, 1743, 1745, 1746, 1748, 1749, 1750, 1752, 1753, 1754, 1756, 1758, 1759, 1760, 1762, 1763, 1764, 1765, 1768, 1769, 1780, 1782, 1783, 1784, 1785, 1786, 1789, 1790, 1792, 1793, 1794, 1795, 1796, 1798, 1802, 1803, 1804, 1805, 1806, 1807, 1809, 1820, 1823, 1824, 1825, 1826, 1827, 1829, 1830, 1832, 1834, 1835, 1836, 1837, 1839, 1840, 1842, 1843, 1845, 1846, 1847, 1849, 1850, 1852, 1853, 1854, 1856, 1857, 1859, 1860, 1862, 1863, 1864, 1865, 1867, 1869, 1870, 1872, 1873, 1874, 1875, 1876, 1879, 1890, 1892, 1893, 1894, 1895, 1896, 1897, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1920, 1923, 1924, 1925, 1926, 1927, 1928, 1930, 1932, 1934, 1935, 1936, 1937, 1938, 1940, 1942, 1943, 1945, 1946, 1947, 1948, 1950, 1952, 1953, 1954, 1956, 1957, 1958, 1960, 1962, 1963, 1964, 1965, 1967, 1968, 1970, 1972, 1973, 1974, 1975, 1976, 1978, 1980, 1982, 1983, 1984, 1985, 1986, 1987, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2031, 2034, 2035, 2036, 2037, 2038, 2039, 2041, 2043, 2045, 2046, 2047, 2048, 2049, 2051, 2053, 2054, 2056, 2057, 2058, 2059, 2061, 2063, 2064, 2065, 2067, 2068, 2069, 2071, 2073, 2074, 2075, 2076, 2078, 2079, 2081, 2083, 2084, 2085, 2086, 2087, 2089, 2091, 2093, 2094, 2095, 2096, 2097, 2098, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2130, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2143, 2145, 2146, 2147, 2148, 2149, 2150, 2153, 2154, 2156, 2157, 2158, 2159, 2160, 2163, 2164, 2165, 2167, 2168, 2169, 2170, 2173, 2174, 2175, 2176, 2178, 2179, 2180, 2183, 2184, 2185, 2186, 2187, 2189, 2190, 2193, 2194, 2195, 2196, 2197, 2198, 2301, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2314, 2315, 2316, 2317, 2318, 2319, 2340, 2341, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2354, 2356, 2357, 2358, 2359, 2360, 2361, 2364, 2365, 2367, 2368, 2369, 2370, 2371, 2374, 2375, 2376, 2378, 2379, 2380, 2381, 2384, 2385, 2386, 2387, 2389, 2390, 2391, 2394, 2395, 2396, 2397, 2398, 2401, 2403, 2405, 2406, 2407, 2408, 2409, 2410, 2413, 2415, 2416, 2417, 2418, 2419, 2430, 2431, 2435, 2436, 2437, 2438, 2439, 2450, 2451, 2453, 2456, 2457, 2458, 2459, 2460, 2461, 2463, 2465, 2467, 2468, 2469, 2470, 2471, 2473, 2475, 2476, 2478, 2479, 2480, 2481, 2483, 2485, 2486, 2487, 2489, 2490, 2491, 2493, 2495, 2496, 2497, 2498, 2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2519, 2530, 2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549, 2560, 2561, 2563, 2564, 2567, 2568, 2569, 2570, 2571, 2573, 2574, 2576, 2578, 2579, 2580, 2581, 2583, 2584, 2586, 2587, 2589, 2590, 2591, 2593, 2594, 2596, 2597, 2598, 2601, 2603, 2604, 2605, 2607, 2608, 2609, 2610, 2613, 2614, 2615, 2617, 2618, 2619, 2630, 2631, 2634, 2635, 2637, 2638, 2639, 2640, 2641, 2643, 2645, 2647, 2648, 2649, 2650, 2651, 2653, 2654, 2657, 2658, 2659, 2670, 2671, 2673, 2674, 2675, 2678, 2679, 2680, 2681, 2683, 2684, 2685, 2687, 2689, 2690, 2691, 2693, 2694, 2695, 2697, 2698, 2701, 2703, 2704, 2705, 2706, 2708, 2709, 2710, 2713, 2714, 2715, 2716, 2718, 2719, 2730, 2731, 2734, 2735, 2736, 2738, 2739, 2740, 2741, 2743, 2745, 2746, 2748, 2749, 2750, 2751, 2753, 2754, 2756, 2758, 2759, 2760, 2761, 2763, 2764, 2765, 2768, 2769, 2780, 2781, 2783, 2784, 2785, 2786, 2789, 2790, 2791, 2793, 2794, 2795, 2796, 2798, 2801, 2803, 2804, 2805, 2806, 2807, 2809, 2810, 2813, 2814, 2815, 2816, 2817, 2819, 2830, 2831, 2834, 2835, 2836, 2837, 2839, 2840, 2841, 2843, 2845, 2846, 2847, 2849, 2850, 2851, 2853, 2854, 2856, 2857, 2859, 2860, 2861, 2863, 2864, 2865, 2867, 2869, 2870, 2871, 2873, 2874, 2875, 2876, 2879, 2890, 2891, 2893, 2894, 2895, 2896, 2897, 2901, 2903, 2904, 2905, 2906, 2907, 2908, 2910, 2913, 2914, 2915, 2916, 2917, 2918, 2930, 2931, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2943, 2945, 2946, 2947, 2948, 2950, 2951, 2953, 2954, 2956, 2957, 2958, 2960, 2961, 2963, 2964, 2965, 2967, 2968, 2970, 2971, 2973, 2974, 2975, 2976, 2978, 2980, 2981, 2983, 2984, 2985, 2986, 2987, 3012, 3014, 3015, 3016, 3017, 3018, 3019, 3021, 3024, 3025, 3026, 3027, 3028, 3029, 3041, 3042, 3045, 3046, 3047, 3048, 3049, 3051, 3052, 3054, 3056, 3057, 3058, 3059, 3061, 3062, 3064, 3065, 3067, 3068, 3069, 3071, 3072, 3074, 3075, 3076, 3078, 3079, 3081, 3082, 3084, 3085, 3086, 3087, 3089, 3091, 3092, 3094, 3095, 3096, 3097, 3098, 3102, 3104, 3105, 3106, 3107, 3108, 3109, 3120, 3124, 3125, 3126, 3127, 3128, 3129, 3140, 3142, 3145, 3146, 3147, 3148, 3149, 3150, 3152, 3154, 3156, 3157, 3158, 3159, 3160, 3162, 3164, 3165, 3167, 3168, 3169, 3170, 3172, 3174, 3175, 3176, 3178, 3179, 3180, 3182, 3184, 3185, 3186, 3187, 3189, 3190, 3192, 3194, 3195, 3196, 3197, 3198, 3201, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3214, 3215, 3216, 3217, 3218, 3219, 3240, 3241, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3254, 3256, 3257, 3258, 3259, 3260, 3261, 3264, 3265, 3267, 3268, 3269, 3270, 3271, 3274, 3275, 3276, 3278, 3279, 3280, 3281, 3284, 3285, 3286, 3287, 3289, 3290, 3291, 3294, 3295, 3296, 3297, 3298, 3401, 3402, 3405, 3406, 3407, 3408, 3409, 3410, 3412, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3425, 3426, 3427, 3428, 3429, 3450, 3451, 3452, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3465, 3467, 3468, 3469, 3470, 3471, 3472, 3475, 3476, 3478, 3479, 3480, 3481, 3482, 3485, 3486, 3487, 3489, 3490, 3491, 3492, 3495, 3496, 3497, 3498, 3501, 3502, 3504, 3506, 3507, 3508, 3509, 3510, 3512, 3514, 3516, 3517, 3518, 3519, 3520, 3521, 3524, 3526, 3527, 3528, 3529, 3540, 3541, 3542, 3546, 3547, 3548, 3549, 3560, 3561, 3562, 3564, 3567, 3568, 3569, 3570, 3571, 3572, 3574, 3576, 3578, 3579, 3580, 3581, 3582, 3584, 3586, 3587, 3589, 3590, 3591, 3592, 3594, 3596, 3597, 3598, 3601, 3602, 3604, 3605, 3607, 3608, 3609, 3610, 3612, 3614, 3615, 3617, 3618, 3619, 3620, 3621, 3624, 3625, 3627, 3628, 3629, 3640, 3641, 3642, 3645, 3647, 3648, 3649, 3650, 3651, 3652, 3654, 3657, 3658, 3659, 3670, 3671, 3672, 3674, 3675, 3678, 3679, 3680, 3681, 3682, 3684, 3685, 3687, 3689, 3690, 3691, 3692, 3694, 3695, 3697, 3698, 3701, 3702, 3704, 3705, 3706, 3708, 3709, 3710, 3712, 3714, 3715, 3716, 3718, 3719, 3720, 3721, 3724, 3725, 3726, 3728, 3729, 3740, 3741, 3742, 3745, 3746, 3748, 3749, 3750, 3751, 3752, 3754, 3756, 3758, 3759, 3760, 3761, 3762, 3764, 3765, 3768, 3769, 3780, 3781, 3782, 3784, 3785, 3786, 3789, 3790, 3791, 3792, 3794, 3795, 3796, 3798, 3801, 3802, 3804, 3805, 3806, 3807, 3809, 3810, 3812, 3814, 3815, 3816, 3817, 3819, 3820, 3821, 3824, 3825, 3826, 3827, 3829, 3840, 3841, 3842, 3845, 3846, 3847, 3849, 3850, 3851, 3852, 3854, 3856, 3857, 3859, 3860, 3861, 3862, 3864, 3865, 3867, 3869, 3870, 3871, 3872, 3874, 3875, 3876, 3879, 3890, 3891, 3892, 3894, 3895, 3896, 3897, 3901, 3902, 3904, 3905, 3906, 3907, 3908, 3910, 3912, 3914, 3915, 3916, 3917, 3918, 3920, 3921, 3924, 3925, 3926, 3927, 3928, 3940, 3941, 3942, 3945, 3946, 3947, 3948, 3950, 3951, 3952, 3954, 3956, 3957, 3958, 3960, 3961, 3962, 3964, 3965, 3967, 3968, 3970, 3971, 3972, 3974, 3975, 3976, 3978, 3980, 3981, 3982, 3984, 3985, 3986, 3987, 4012, 4013, 4015, 4016, 4017, 4018, 4019, 4021, 4023, 4025, 4026, 4027, 4028, 4029, 4031, 4032, 4035, 4036, 4037, 4038, 4039, 4051, 4052, 4053, 4056, 4057, 4058, 4059, 4061, 4062, 4063, 4065, 4067, 4068, 4069, 4071, 4072, 4073, 4075, 4076, 4078, 4079, 4081, 4082, 4083, 4085, 4086, 4087, 4089, 4091, 4092, 4093, 4095, 4096, 4097, 4098, 4102, 4103, 4105, 4106, 4107, 4108, 4109, 4120, 4123, 4125, 4126, 4127, 4128, 4129, 4130, 4132, 4135, 4136, 4137, 4138, 4139, 4150, 4152, 4153, 4156, 4157, 4158, 4159, 4160, 4162, 4163, 4165, 4167, 4168, 4169, 4170, 4172, 4173, 4175, 4176, 4178, 4179, 4180, 4182, 4183, 4185, 4186, 4187, 4189, 4190, 4192, 4193, 4195, 4196, 4197, 4198, 4201, 4203, 4205, 4206, 4207, 4208, 4209, 4210, 4213, 4215, 4216, 4217, 4218, 4219, 4230, 4231, 4235, 4236, 4237, 4238, 4239, 4250, 4251, 4253, 4256, 4257, 4258, 4259, 4260, 4261, 4263, 4265, 4267, 4268, 4269, 4270, 4271, 4273, 4275, 4276, 4278, 4279, 4280, 4281, 4283, 4285, 4286, 4287, 4289, 4290, 4291, 4293, 4295, 4296, 4297, 4298, 4301, 4302, 4305, 4306, 4307, 4308, 4309, 4310, 4312, 4315, 4316, 4317, 4318, 4319, 4320, 4321, 4325, 4326, 4327, 4328, 4329, 4350, 4351, 4352, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 4365, 4367, 4368, 4369, 4370, 4371, 4372, 4375, 4376, 4378, 4379, 4380, 4381, 4382, 4385, 4386, 4387, 4389, 4390, 4391, 4392, 4395, 4396, 4397, 4398, 4501, 4502, 4503, 4506, 4507, 4508, 4509, 4510, 4512, 4513, 4516, 4517, 4518, 4519, 4520, 4521, 4523, 4526, 4527, 4528, 4529, 4530, 4531, 4532, 4536, 4537, 4538, 4539, 4560, 4561, 4562, 4563, 4567, 4568, 4569, 4570, 4571, 4572, 4573, 4576, 4578, 4579, 4580, 4581, 4582, 4583, 4586, 4587, 4589, 4590, 4591, 4592, 4593, 4596, 4597, 4598, 4601, 4602, 4603, 4605, 4607, 4608, 4609, 4610, 4612, 4613, 4615, 4617, 4618, 4619, 4620, 4621, 4623, 4625, 4627, 4628, 4629, 4630, 4631, 4632, 4635, 4637, 4638, 4639, 4650, 4651, 4652, 4653, 4657, 4658, 4659, 4670, 4671, 4672, 4673, 4675, 4678, 4679, 4680, 4681, 4682, 4683, 4685, 4687, 4689, 4690, 4691, 4692, 4693, 4695, 4697, 4698, 4701, 4702, 4703, 4705, 4706, 4708, 4709, 4710, 4712, 4713, 4715, 4716, 4718, 4719, 4720, 4721, 4723, 4725, 4726, 4728, 4729, 4730, 4731, 4732, 4735, 4736, 4738, 4739, 4750, 4751, 4752, 4753, 4756, 4758, 4759, 4760, 4761, 4762, 4763, 4765, 4768, 4769, 4780, 4781, 4782, 4783, 4785, 4786, 4789, 4790, 4791, 4792, 4793, 4795, 4796, 4798, 4801, 4802, 4803, 4805, 4806, 4807, 4809, 4810, 4812, 4813, 4815, 4816, 4817, 4819, 4820, 4821, 4823, 4825, 4826, 4827, 4829, 4830, 4831, 4832, 4835, 4836, 4837, 4839, 4850, 4851, 4852, 4853, 4856, 4857, 4859, 4860, 4861, 4862, 4863, 4865, 4867, 4869, 4870, 4871, 4872, 4873, 4875, 4876, 4879, 4890, 4891, 4892, 4893, 4895, 4896, 4897, 4901, 4902, 4903, 4905, 4906, 4907, 4908, 4910, 4912, 4913, 4915, 4916, 4917, 4918, 4920, 4921, 4923, 4925, 4926, 4927, 4928, 4930, 4931, 4932, 4935, 4936, 4937, 4938, 4950, 4951, 4952, 4953, 4956, 4957, 4958, 4960, 4961, 4962, 4963, 4965, 4967, 4968, 4970, 4971, 4972, 4973, 4975, 4976, 4978, 4980, 4981, 4982, 4983, 4985, 4986, 4987, 5012, 5013, 5014, 5016, 5017, 5018, 5019, 5021, 5023, 5024, 5026, 5027, 5028, 5029, 5031, 5032, 5034, 5036, 5037, 5038, 5039, 5041, 5042, 5043, 5046, 5047, 5048, 5049, 5061, 5062, 5063, 5064, 5067, 5068, 5069, 5071, 5072, 5073, 5074, 5076, 5078, 5079, 5081, 5082, 5083, 5084, 5086, 5087, 5089, 5091, 5092, 5093, 5094, 5096, 5097, 5098, 5102, 5103, 5104, 5106, 5107, 5108, 5109, 5120, 5123, 5124, 5126, 5127, 5128, 5129, 5130, 5132, 5134, 5136, 5137, 5138, 5139, 5140, 5142, 5143, 5146, 5147, 5148, 5149, 5160, 5162, 5163, 5164, 5167, 5168, 5169, 5170, 5172, 5173, 5174, 5176, 5178, 5179, 5180, 5182, 5183, 5184, 5186, 5187, 5189, 5190, 5192, 5193, 5194, 5196, 5197, 5198, 5201, 5203, 5204, 5206, 5207, 5208, 5209, 5210, 5213, 5214, 5216, 5217, 5218, 5219, 5230, 5231, 5234, 5236, 5237, 5238, 5239, 5240, 5241, 5243, 5246, 5247, 5248, 5249, 5260, 5261, 5263, 5264, 5267, 5268, 5269, 5270, 5271, 5273, 5274, 5276, 5278, 5279, 5280, 5281, 5283, 5284, 5286, 5287, 5289, 5290, 5291, 5293, 5294, 5296, 5297, 5298, 5301, 5302, 5304, 5306, 5307, 5308, 5309, 5310, 5312, 5314, 5316, 5317, 5318, 5319, 5320, 5321, 5324, 5326, 5327, 5328, 5329, 5340, 5341, 5342, 5346, 5347, 5348, 5349, 5360, 5361, 5362, 5364, 5367, 5368, 5369, 5370, 5371, 5372, 5374, 5376, 5378, 5379, 5380, 5381, 5382, 5384, 5386, 5387, 5389, 5390, 5391, 5392, 5394, 5396, 5397, 5398, 5401, 5402, 5403, 5406, 5407, 5408, 5409, 5410, 5412, 5413, 5416, 5417, 5418, 5419, 5420, 5421, 5423, 5426, 5427, 5428, 5429, 5430, 5431, 5432, 5436, 5437, 5438, 5439, 5460, 5461, 5462, 5463, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5476, 5478, 5479, 5480, 5481, 5482, 5483, 5486, 5487, 5489, 5490, 5491, 5492, 5493, 5496, 5497, 5498, 5601, 5602, 5603, 5604, 5607, 5608, 5609, 5610, 5612, 5613, 5614, 5617, 5618, 5619, 5620, 5621, 5623, 5624, 5627, 5628, 5629, 5630, 5631, 5632, 5634, 5637, 5638, 5639, 5640, 5641, 5642, 5643, 5647, 5648, 5649, 5670, 5671, 5672, 5673, 5674, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5687, 5689, 5690, 5691, 5692, 5693, 5694, 5697, 5698, 5701, 5702, 5703, 5704, 5706, 5708, 5709, 5710, 5712, 5713, 5714, 5716, 5718, 5719, 5720, 5721, 5723, 5724, 5726, 5728, 5729, 5730, 5731, 5732, 5734, 5736, 5738, 5739, 5740, 5741, 5742, 5743, 5746, 5748, 5749, 5760, 5761, 5762, 5763, 5764, 5768, 5769, 5780, 5781, 5782, 5783, 5784, 5786, 5789, 5790, 5791, 5792, 5793, 5794, 5796, 5798, 5801, 5802, 5803, 5804, 5806, 5807, 5809, 5810, 5812, 5813, 5814, 5816, 5817, 5819, 5820, 5821, 5823, 5824, 5826, 5827, 5829, 5830, 5831, 5832, 5834, 5836, 5837, 5839, 5840, 5841, 5842, 5843, 5846, 5847, 5849, 5860, 5861, 5862, 5863, 5864, 5867, 5869, 5870, 5871, 5872, 5873, 5874, 5876, 5879, 5890, 5891, 5892, 5893, 5894, 5896, 5897, 5901, 5902, 5903, 5904, 5906, 5907, 5908, 5910, 5912, 5913, 5914, 5916, 5917, 5918, 5920, 5921, 5923, 5924, 5926, 5927, 5928, 5930, 5931, 5932, 5934, 5936, 5937, 5938, 5940, 5941, 5942, 5943, 5946, 5947, 5948, 5960, 5961, 5962, 5963, 5964, 5967, 5968, 5970, 5971, 5972, 5973, 5974, 5976, 5978, 5980, 5981, 5982, 5983, 5984, 5986, 5987, 6012, 6013, 6014, 6015, 6017, 6018, 6019, 6021, 6023, 6024, 6025, 6027, 6028, 6029, 6031, 6032, 6034, 6035, 6037, 6038, 6039, 6041, 6042, 6043, 6045, 6047, 6048, 6049, 6051, 6052, 6053, 6054, 6057, 6058, 6059, 6071, 6072, 6073, 6074, 6075, 6078, 6079, 6081, 6082, 6083, 6084, 6085, 6087, 6089, 6091, 6092, 6093, 6094, 6095, 6097, 6098, 6102, 6103, 6104, 6105, 6107, 6108, 6109, 6120, 6123, 6124, 6125, 6127, 6128, 6129, 6130, 6132, 6134, 6135, 6137, 6138, 6139, 6140, 6142, 6143, 6145, 6147, 6148, 6149, 6150, 6152, 6153, 6154, 6157, 6158, 6159, 6170, 6172, 6173, 6174, 6175, 6178, 6179, 6180, 6182, 6183, 6184, 6185, 6187, 6189, 6190, 6192, 6193, 6194, 6195, 6197, 6198, 6201, 6203, 6204, 6205, 6207, 6208, 6209, 6210, 6213, 6214, 6215, 6217, 6218, 6219, 6230, 6231, 6234, 6235, 6237, 6238, 6239, 6240, 6241, 6243, 6245, 6247, 6248, 6249, 6250, 6251, 6253, 6254, 6257, 6258, 6259, 6270, 6271, 6273, 6274, 6275, 6278, 6279, 6280, 6281, 6283, 6284, 6285, 6287, 6289, 6290, 6291, 6293, 6294, 6295, 6297, 6298, 6301, 6302, 6304, 6305, 6307, 6308, 6309, 6310, 6312, 6314, 6315, 6317, 6318, 6319, 6320, 6321, 6324, 6325, 6327, 6328, 6329, 6340, 6341, 6342, 6345, 6347, 6348, 6349, 6350, 6351, 6352, 6354, 6357, 6358, 6359, 6370, 6371, 6372, 6374, 6375, 6378, 6379, 6380, 6381, 6382, 6384, 6385, 6387, 6389, 6390, 6391, 6392, 6394, 6395, 6397, 6398, 6401, 6402, 6403, 6405, 6407, 6408, 6409, 6410, 6412, 6413, 6415, 6417, 6418, 6419, 6420, 6421, 6423, 6425, 6427, 6428, 6429, 6430, 6431, 6432, 6435, 6437, 6438, 6439, 6450, 6451, 6452, 6453, 6457, 6458, 6459, 6470, 6471, 6472, 6473, 6475, 6478, 6479, 6480, 6481, 6482, 6483, 6485, 6487, 6489, 6490, 6491, 6492, 6493, 6495, 6497, 6498, 6501, 6502, 6503, 6504, 6507, 6508, 6509, 6510, 6512, 6513, 6514, 6517, 6518, 6519, 6520, 6521, 6523, 6524, 6527, 6528, 6529, 6530, 6531, 6532, 6534, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6547, 6548, 6549, 6570, 6571, 6572, 6573, 6574, 6578, 6579, 6580, 6581, 6582, 6583, 6584, 6587, 6589, 6590, 6591, 6592, 6593, 6594, 6597, 6598, 6701, 6702, 6703, 6704, 6705, 6708, 6709, 6710, 6712, 6713, 6714, 6715, 6718, 6719, 6720, 6721, 6723, 6724, 6725, 6728, 6729, 6730, 6731, 6732, 6734, 6735, 6738, 6739, 6740, 6741, 6742, 6743, 6745, 6748, 6749, 6750, 6751, 6752, 6753, 6754, 6758, 6759, 6780, 6781, 6782, 6783, 6784, 6785, 6789, 6790, 6791, 6792, 6793, 6794, 6795, 6798, 6801, 6802, 6803, 6804, 6805, 6807, 6809, 6810, 6812, 6813, 6814, 6815, 6817, 6819, 6820, 6821, 6823, 6824, 6825, 6827, 6829, 6830, 6831, 6832, 6834, 6835, 6837, 6839, 6840, 6841, 6842, 6843, 6845, 6847, 6849, 6850, 6851, 6852, 6853, 6854, 6857, 6859, 6870, 6871, 6872, 6873, 6874, 6875, 6879, 6890, 6891, 6892, 6893, 6894, 6895, 6897, 6901, 6902, 6903, 6904, 6905, 6907, 6908, 6910, 6912, 6913, 6914, 6915, 6917, 6918, 6920, 6921, 6923, 6924, 6925, 6927, 6928, 6930, 6931, 6932, 6934, 6935, 6937, 6938, 6940, 6941, 6942, 6943, 6945, 6947, 6948, 6950, 6951, 6952, 6953, 6954, 6957, 6958, 6970, 6971, 6972, 6973, 6974, 6975, 6978, 6980, 6981, 6982, 6983, 6984, 6985, 6987, 7012, 7013, 7014, 7015, 7016, 7018, 7019, 7021, 7023, 7024, 7025, 7026, 7028, 7029, 7031, 7032, 7034, 7035, 7036, 7038, 7039, 7041, 7042, 7043, 7045, 7046, 7048, 7049, 7051, 7052, 7053, 7054, 7056, 7058, 7059, 7061, 7062, 7063, 7064, 7065, 7068, 7069, 7081, 7082, 7083, 7084, 7085, 7086, 7089, 7091, 7092, 7093, 7094, 7095, 7096, 7098, 7102, 7103, 7104, 7105, 7106, 7108, 7109, 7120, 7123, 7124, 7125, 7126, 7128, 7129, 7130, 7132, 7134, 7135, 7136, 7138, 7139, 7140, 7142, 7143, 7145, 7146, 7148, 7149, 7150, 7152, 7153, 7154, 7156, 7158, 7159, 7160, 7162, 7163, 7164, 7165, 7168, 7169, 7180, 7182, 7183, 7184, 7185, 7186, 7189, 7190, 7192, 7193, 7194, 7195, 7196, 7198, 7201, 7203, 7204, 7205, 7206, 7208, 7209, 7210, 7213, 7214, 7215, 7216, 7218, 7219, 7230, 7231, 7234, 7235, 7236, 7238, 7239, 7240, 7241, 7243, 7245, 7246, 7248, 7249, 7250, 7251, 7253, 7254, 7256, 7258, 7259, 7260, 7261, 7263, 7264, 7265, 7268, 7269, 7280, 7281, 7283, 7284, 7285, 7286, 7289, 7290, 7291, 7293, 7294, 7295, 7296, 7298, 7301, 7302, 7304, 7305, 7306, 7308, 7309, 7310, 7312, 7314, 7315, 7316, 7318, 7319, 7320, 7321, 7324, 7325, 7326, 7328, 7329, 7340, 7341, 7342, 7345, 7346, 7348, 7349, 7350, 7351, 7352, 7354, 7356, 7358, 7359, 7360, 7361, 7362, 7364, 7365, 7368, 7369, 7380, 7381, 7382, 7384, 7385, 7386, 7389, 7390, 7391, 7392, 7394, 7395, 7396, 7398, 7401, 7402, 7403, 7405, 7406, 7408, 7409, 7410, 7412, 7413, 7415, 7416, 7418, 7419, 7420, 7421, 7423, 7425, 7426, 7428, 7429, 7430, 7431, 7432, 7435, 7436, 7438, 7439, 7450, 7451, 7452, 7453, 7456, 7458, 7459, 7460, 7461, 7462, 7463, 7465, 7468, 7469, 7480, 7481, 7482, 7483, 7485, 7486, 7489, 7490, 7491, 7492, 7493, 7495, 7496, 7498, 7501, 7502, 7503, 7504, 7506, 7508, 7509, 7510, 7512, 7513, 7514, 7516, 7518, 7519, 7520, 7521, 7523, 7524, 7526, 7528, 7529, 7530, 7531, 7532, 7534, 7536, 7538, 7539, 7540, 7541, 7542, 7543, 7546, 7548, 7549, 7560, 7561, 7562, 7563, 7564, 7568, 7569, 7580, 7581, 7582, 7583, 7584, 7586, 7589, 7590, 7591, 7592, 7593, 7594, 7596, 7598, 7601, 7602, 7603, 7604, 7605, 7608, 7609, 7610, 7612, 7613, 7614, 7615, 7618, 7619, 7620, 7621, 7623, 7624, 7625, 7628, 7629, 7630, 7631, 7632, 7634, 7635, 7638, 7639, 7640, 7641, 7642, 7643, 7645, 7648, 7649, 7650, 7651, 7652, 7653, 7654, 7658, 7659, 7680, 7681, 7682, 7683, 7684, 7685, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7698, 7801, 7802, 7803, 7804, 7805, 7806, 7809, 7810, 7812, 7813, 7814, 7815, 7816, 7819, 7820, 7821, 7823, 7824, 7825, 7826, 7829, 7830, 7831, 7832, 7834, 7835, 7836, 7839, 7840, 7841, 7842, 7843, 7845, 7846, 7849, 7850, 7851, 7852, 7853, 7854, 7856, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7869, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7901, 7902, 7903, 7904, 7905, 7906, 7908, 7910, 7912, 7913, 7914, 7915, 7916, 7918, 7920, 7921, 7923, 7924, 7925, 7926, 7928, 7930, 7931, 7932, 7934, 7935, 7936, 7938, 7940, 7941, 7942, 7943, 7945, 7946, 7948, 7950, 7951, 7952, 7953, 7954, 7956, 7958, 7960, 7961, 7962, 7963, 7964, 7965, 7968, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 8012, 8013, 8014, 8015, 8016, 8017, 8019, 8021, 8023, 8024, 8025, 8026, 8027, 8029, 8031, 8032, 8034, 8035, 8036, 8037, 8039, 8041, 8042, 8043, 8045, 8046, 8047, 8049, 8051, 8052, 8053, 8054, 8056, 8057, 8059, 8061, 8062, 8063, 8064, 8065, 8067, 8069, 8071, 8072, 8073, 8074, 8075, 8076, 8079, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8102, 8103, 8104, 8105, 8106, 8107, 8109, 8120, 8123, 8124, 8125, 8126, 8127, 8129, 8130, 8132, 8134, 8135, 8136, 8137, 8139, 8140, 8142, 8143, 8145, 8146, 8147, 8149, 8150, 8152, 8153, 8154, 8156, 8157, 8159, 8160, 8162, 8163, 8164, 8165, 8167, 8169, 8170, 8172, 8173, 8174, 8175, 8176, 8179, 8190, 8192, 8193, 8194, 8195, 8196, 8197, 8201, 8203, 8204, 8205, 8206, 8207, 8209, 8210, 8213, 8214, 8215, 8216, 8217, 8219, 8230, 8231, 8234, 8235, 8236, 8237, 8239, 8240, 8241, 8243, 8245, 8246, 8247, 8249, 8250, 8251, 8253, 8254, 8256, 8257, 8259, 8260, 8261, 8263, 8264, 8265, 8267, 8269, 8270, 8271, 8273, 8274, 8275, 8276, 8279, 8290, 8291, 8293, 8294, 8295, 8296, 8297, 8301, 8302, 8304, 8305, 8306, 8307, 8309, 8310, 8312, 8314, 8315, 8316, 8317, 8319, 8320, 8321, 8324, 8325, 8326, 8327, 8329, 8340, 8341, 8342, 8345, 8346, 8347, 8349, 8350, 8351, 8352, 8354, 8356, 8357, 8359, 8360, 8361, 8362, 8364, 8365, 8367, 8369, 8370, 8371, 8372, 8374, 8375, 8376, 8379, 8390, 8391, 8392, 8394, 8395, 8396, 8397, 8401, 8402, 8403, 8405, 8406, 8407, 8409, 8410, 8412, 8413, 8415, 8416, 8417, 8419, 8420, 8421, 8423, 8425, 8426, 8427, 8429, 8430, 8431, 8432, 8435, 8436, 8437, 8439, 8450, 8451, 8452, 8453, 8456, 8457, 8459, 8460, 8461, 8462, 8463, 8465, 8467, 8469, 8470, 8471, 8472, 8473, 8475, 8476, 8479, 8490, 8491, 8492, 8493, 8495, 8496, 8497, 8501, 8502, 8503, 8504, 8506, 8507, 8509, 8510, 8512, 8513, 8514, 8516, 8517, 8519, 8520, 8521, 8523, 8524, 8526, 8527, 8529, 8530, 8531, 8532, 8534, 8536, 8537, 8539, 8540, 8541, 8542, 8543, 8546, 8547, 8549, 8560, 8561, 8562, 8563, 8564, 8567, 8569, 8570, 8571, 8572, 8573, 8574, 8576, 8579, 8590, 8591, 8592, 8593, 8594, 8596, 8597, 8601, 8602, 8603, 8604, 8605, 8607, 8609, 8610, 8612, 8613, 8614, 8615, 8617, 8619, 8620, 8621, 8623, 8624, 8625, 8627, 8629, 8630, 8631, 8632, 8634, 8635, 8637, 8639, 8640, 8641, 8642, 8643, 8645, 8647, 8649, 8650, 8651, 8652, 8653, 8654, 8657, 8659, 8670, 8671, 8672, 8673, 8674, 8675, 8679, 8690, 8691, 8692, 8693, 8694, 8695, 8697, 8701, 8702, 8703, 8704, 8705, 8706, 8709, 8710, 8712, 8713, 8714, 8715, 8716, 8719, 8720, 8721, 8723, 8724, 8725, 8726, 8729, 8730, 8731, 8732, 8734, 8735, 8736, 8739, 8740, 8741, 8742, 8743, 8745, 8746, 8749, 8750, 8751, 8752, 8753, 8754, 8756, 8759, 8760, 8761, 8762, 8763, 8764, 8765, 8769, 8790, 8791, 8792, 8793, 8794, 8795, 8796, 8901, 8902, 8903, 8904, 8905, 8906, 8907, 8910, 8912, 8913, 8914, 8915, 8916, 8917, 8920, 8921, 8923, 8924, 8925, 8926, 8927, 8930, 8931, 8932, 8934, 8935, 8936, 8937, 8940, 8941, 8942, 8943, 8945, 8946, 8947, 8950, 8951, 8952, 8953, 8954, 8956, 8957, 8960, 8961, 8962, 8963, 8964, 8965, 8967, 8970, 8971, 8972, 8973, 8974, 8975, 8976, 9012]
for i in YEAR_LIST:
	if i > INPUT_YEAR:
		print(i)
		break


year = int(input())

def is_distinct(year):
	return len(set((c for c in str(year)))) == 4
year += 1
while not is_distinct(year):
	year += 1
print(year)


n = int(input())
while 1:
	n += 1
	a = list(str(n))
	t = 0
	for i in range(len(a)):
		c = 0
		for j in range(i + 1, len(a)):
			if a[i] == a[j]:
				c = 1
				break
		if c == 1:
			t = 1
			break
	if t == 0:
		break
print(n)


import sys
INT_MAX = sys.maxsize

def countDistinct(n):
	arr = [0] * 10
	count = 0
	while n != 0:
		r = int(n % 10)
		arr[r] = 1
		n //= 10
	for i in range(10):
		if arr[i] != 0:
			count += 1
	return count

def countDigit(n):
	c = 0
	while n != 0:
		r = n % 10
		c += 1
		n //= 10
	return c

def nextNumberDistinctDigit(n):
	while n < INT_MAX:
		distinct_digits = countDistinct(n + 1)
		total_digits = countDigit(n + 1)
		if distinct_digits == total_digits:
			return n + 1
		else:
			n += 1
	return -1
n = int(input())
print(nextNumberDistinctDigit(n))


n = int(input())
while 1:
	n += 1
	if len(set(str(n))) == len(str(n)):
		print(n)
		break


y = int(input())
ls = list(str(y))
i = y + 1
while True:
	if len(set(str(i))) == 4:
		print(i)
		break
	i += 1


ch1 = int(input()) + 1
ch = str(ch1)
se = set(ch)
while len(se) < 4:
	ch1 += 1
	ch = str(ch1)
	se = set(ch)
print(ch)


def distdig(n):
	s = str(n)
	l = []
	for i in s:
		l.append(i)
	l = list(set(l))
	k = len(l)
	del l
	return k

def nextnum(n):
	while True:
		dist = distdig(n + 1)
		total = 4
		if dist == total:
			return n + 1
		else:
			n += 1
n = int(input())
print(nextnum(n))


n = int(input())
a = [0] * 4

def by(n):
	for i in range(0, 4):
		a[i] = n % 10
		n = n // 10
	for i in range(0, 4):
		for j in range(i + 1, 4):
			if a[j] == a[i]:
				return 0
	return 1
while True:
	n += 1
	if by(n):
		print(n)
		break


i = input()
j = int(i)
while True:
	j = j + 1
	k = str(j)
	if k.count(k[0]) == 1 and k.count(k[1]) == 1 and (k.count(k[2]) == 1):
		print(j)
		break


n = int(input())
for i in range(n + 1, 10000):
	if len({int(j) for j in ' '.join(str(i)).split()}) == 4:
		print(i)
		break


from collections import Counter

def proA(n):
	for i in range(n + 1, 100001):
		st = str(i)
		dic = Counter(st)
		if list(dic.values()) == [1, 1, 1, 1]:
			return st
n = int(input())
print(proA(n))


n = int(input())
nextyr1 = n + 1
nextyr = str(nextyr1)
nextyr = list(nextyr)
while True:
	if len(set(nextyr)) == 4:
		break
	nextyr1 = nextyr1 + 1
	nextyr = str(nextyr1)
	nextyr = list(nextyr)
strings = [str(integer) for integer in nextyr]
a_string = ''.join(strings)
an_integer = int(a_string)
print(an_integer)


n = input()
count = int(n) + 1
arr = []

def brute(arr, count):
	arr = list(map(int, str(count)))
	result = check(arr)
	arr.clear()
	if result == True:
		return brute(arr, count + 1)
	else:
		return count

def check(listOfElems):
	if len(listOfElems) == len(set(listOfElems)):
		return False
	else:
		return True
print(brute(arr, count))


def check(m):
	m = str(m)
	for i in range(len(m) - 1):
		for j in range(i + 1, len(m)):
			if m[i] == m[j]:
				return False
	return True
n = int(input())
m = n + 1
while not check(m):
	m += 1
print(m)


n = input()
year = [int(x) for x in str(n)]
numbers = []
for i in range(int(n) + 1, 9013):
	a = (i - i % 1000) / 1000
	b = (i % 1000 - i % 100) / 100
	c = (i % 100 - i % 10) / 10
	d = i % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		numbers.append(i)
numbers.sort()
print(numbers[0])


x = int(input())
x += 1
while len(set(str(x))) != 4:
	x += 1
print(x)


x = input()
while 1 == 1:
	f = 1
	x = int(x)
	x += 1
	x = str(x)
	for i in range(4):
		for j in range(4):
			if i != j and x[i] == x[j]:
				f = 0
	if f == 1:
		break
print(x)


def isequal(n, arr):
	s = str(n)
	for i in range(len(s)):
		if arr[int(s[i])]:
			return 1
		else:
			arr[int(s[i])] = 1
	return 0
n = int(input()) + 1
arr = [0] * 10
while isequal(n, arr):
	n += 1
	arr = [0] * 10
print(n, end='')


from collections import Counter
y = int(input())
while True:
	y += 1
	a = Counter(str(y))
	if len(a) == 4:
		print(y)
		break
	else:
		continue


s = input()
x = int(s) + 1
k = str(x)
p = set(k)
while len(p) != 4:
	x += 1
	k = str(x)
	p = set(k)
print(k)


n = int(input())

def alik(n):
	l = str(n)
	for i in range(4):
		for j in range(i + 1, 4):
			if i != 3 and l[i] == l[j]:
				return 1
	return 0
while 1:
	n += 1
	if alik(n) == 0:
		break
print(n)


x = input()
y = int(x) + 1
z = set(str(y))
while len(''.join(z)) < 4:
	y = y + 1
	z = set(str(y))
else:
	print(y)


n = int(input())
status = -1
temp = n + 1
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
while status == -1:
	temp2 = str(temp)
	total = [0] * 10
	cek = 0
	for i in range(len(temp2)):
		for j in range(len(arr)):
			if temp2[i] == arr[j]:
				total[j] += 1
	for i in range(len(total)):
		if total[i] == 1:
			cek += 1
	if cek == 4:
		print(temp2)
		status = 0
		break
	temp += 1


N = int(input(''))

def YaEsta(X, N):
	Ayuda = -1
	for K in range(len(N)):
		if N[K] == X:
			Ayuda = 1
	return Ayuda

def Descomponer(N):
	NA = []
	while N > 0:
		Ud = N % 10
		X = YaEsta(Ud, NA)
		if X == -1:
			NA = NA + [Ud]
			N = N // 10
		else:
			break
	if len(NA) == 4:
		return 1
	else:
		return 0
K = N + 1
while K < 9013:
	X = Descomponer(K)
	if X == 1:
		print(K)
		break
	else:
		K = K + 1


a = int(input())
while 1:
	a += 1
	n = str(a)
	l = set([])
	for i in n:
		l.add(i)
	if len(l) == 4:
		break
print(a)


def checker(s):
	s = list(str(s))
	return len(set(s)) == len(s)
year = int(input())
year += 1
while not checker(year):
	year += 1
print(year)


y = int(input())
y += 1
v = [c for c in str(y)]
c = len(v)
l = len(list(set(v)))
while not l == c:
	y += 1
	v = [c for c in str(y)]
	c = len(v)
	l = len(list(set(v)))
print(y)


import math
x = int(input())
while True:
	x += 1
	if len(set(str(x))) == 4:
		print(x)
		break


def dis(a):
	lis = list(str(a))
	for i in range(4):
		for j in range(4):
			if i != j and lis[i] == lis[j]:
				return True
	return False
num = int(input())
num += 1
while dis(num):
	num += 1
print(num)


y = str(input())
y_int = int(y)
dist = 0
while dist != 1:
	count = 0
	y_int = y_int + 1
	y = str(y_int)
	digits = []
	for x in y:
		digits.append(x)
	for i in range(len(y) - 1):
		for j in range(i + 1, len(y)):
			if digits[i] == digits[j]:
				count = count + 1
	if count == 0:
		dist = 1
	else:
		dist = 0
print(y_int)


y = int(input()) + 1
s = list(str(y))
found = True
while found:
	found = False
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			if s[i] == s[j]:
				exp = len(s) - j - 1
				y += pow(10, exp) - y % pow(10, exp)
				s = str(y)
				found = True
print(y)


yr = int(input()) + 1
while len(set(list(str(yr)))) < 4:
	yr += 1
print(yr)


def checker(a):
	return len(list(str(a))) == len(set(list(str(a))))
y = int(input())
y += 1
while not checker(y):
	y += 1
print(y)


y = input()
y = int(y) + 1
while True:
	y = str(y)
	if y[0] != y[1] and y[1] != y[2] and (y[2] != y[3]) and (y[0] != y[3]) and (y[0] != y[2]) and (y[1] != y[3]):
		print(y)
		break
	else:
		y = int(y) + 1


y = input()
t = int(y)
while True:
	t = t + 1
	listt = list(str(t))
	if listt[1] != listt[0] and listt[0] != listt[2] != listt[1] and (listt[2] != listt[3] != listt[1]) and (listt[3] != listt[0]):
		print(t)
		break


s = input()
inp = int(s)
for i in range(inp + 1, 9013):
	i = str(i)
	x = set(i)
	if len(x) == 4:
		print(i)
		break


a = int(input())
true = True
num = 0
b = a + 1
while true:
	c = []
	for i in str(b):
		c.append(i)
	ture = True
	nums = []
	for i in c:
		if i not in nums:
			nums.append(i)
		else:
			ture = False
	if ture:
		true = False
		num = b
	b += 1
print(num)


y = int(input()) + 1
while 1:
	if len(list(str(y))) == len(set(list(str(y)))):
		print(y)
		break
	y += 1


y = int(input())
x = [0] * 4
for i in range(y + 1, 12001):
	i2 = i
	for j in range(4):
		x[j] = i % 10
		i //= 10
	if len(set(x)) == 4:
		print(i2)
		break


from collections import Counter

def beautifulYear():
	y = int(input().strip())
	for i in range(y + 1, 10000):
		l = len(Counter(str(i)).keys())
		if l == 4:
			return i
print(beautifulYear())


def isdistinct(year):
	year = str(year)
	new_year = ''
	for i in year:
		if i not in new_year:
			new_year += i
	if len(new_year) == len(year):
		return True
	else:
		return False
n = int(input()) + 1
while not isdistinct(n):
	n += 1
else:
	print(n)


def solve():
	year = int(input()) + 1
	while len(set(str(year))) != 4:
		year += 1
	print(year)
solve()


a = int(input())
a += 1
while str(a) != ''.join(sorted(set(str(a)), key=str(a).index)):
	a += 1
print(a)


n = input()
m = int(n)
b = True
m = m + 1
while b:
	m = str(m)
	f = True
	for i in range(3):
		x = m[i]
		for j in range(i + 1, 4):
			if x == m[j]:
				f = False
				break
	if f == True:
		print(m)
		b == False
		break
	m = int(m)
	m = m + 1


x = int(input())
i = 1
k = 0
j = ''
while True:
	k = x + i
	j = str(k)
	if j[0] != j[1] != j[2] != j[3] and j[1] != j[2] != j[0] != j[3] and (j[2] != j[1] != j[0] != j[3]) and (j[3] != j[1] != j[2] != j[0]):
		print(k)
		break
	i = i + 1


N = int(input('')) + 1
while len(set(str(N))) < 4:
	N += 1
print(N)


import sys

def rr():
	return sys.stdin.readline().rstrip()
rp = print

def print(*args, **kwargs):
	rp('DBG:# ', *args, **kwargs, file=sys.stderr)

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))

def rrle():
	return (line.rstrip() for line in sys.stdin.readlines())

def rrtl():
	return [tuple(map(int, l.split())) for l in rrle()]
from collections import defaultdict

def mus(d=lambda : 0):
	return defaultdict(lambda : defaultdict(d))

def dd0(d=lambda : 0):
	return defaultdict(d)

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def fltn(a):
	(i for sub in a for i in sub)

def yn(x):
	return 'YES' if x else 'NO'

def cpc(arr):
	return zip(arr, arr[1:])
from itertools import accumulate
from itertools import groupby
from itertools import permutations

def grp(x, key=None):
	return ((i, sum((1 for _ in g))) for (i, g) in groupby(x, key=key))
import math

def rnar():
	return (*rrl(), rrl())

def rn():
	return (*rrl(),)

def dpp(a, b=''):
	print('#| {} |#:^ {} ^:'.format(a, b))

def str_join(i, sep=' '):
	return sep.join(map(str, i))
MOD17 = 10 ** 9 + 7

def read():
	return (rri(),)

def solve(x):
	x += 1
	while True:
		if all((*(str(x)[0] != i for (num, i) in enumerate(str(x)) if num != 0), *(str(x)[1] != i for (num, i) in enumerate(str(x)) if num != 1), *(str(x)[2] != i for (num, i) in enumerate(str(x)) if num != 2), *(str(x)[3] != i for (num, i) in enumerate(str(x)) if num != 3))):
			break
		x += 1
	return x
test_count = 1
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	rp(result)


n = int(input())
for i in range(n + 1, 100000000):
	r = i
	p = []
	while r > 0:
		x = r % 10
		p.append(x)
		r = r // 10
	l1 = len(p)
	s = set(p)
	l2 = len(s)
	if l1 == l2:
		print(i)
		break


def is_good_year(y):
	digits = {int(i) for i in str(y)}
	if len(digits) == 4:
		return True
	else:
		return False

def get_good_year(y):
	y += 1
	while not is_good_year(y):
		y += 1
	return y
year = int(input())
print(get_good_year(year))


def beYear():
	n = int(input())
	z = n
	r1 = r2 = r3 = r4 = 0
	if 1000 <= n and n <= 9000:
		while r1 == r2 or r1 == r3 or r1 == r4 or (r2 == r3) or (r2 == r4) or (r3 == r4):
			n = z = z + 1
			r1 = n % 10
			n = n // 10
			r2 = n % 10
			n = n // 10
			r3 = n % 10
			n = n // 10
			r4 = n % 10
			n = n // 10
		print(z)
beYear()


n = int(input())
while True:
	n += 1
	l = str(n)
	a = int(l[0])
	b = int(l[1])
	c = int(l[2])
	d = int(l[3])
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(l)
		break


now = int(input())
while True:
	now += 1
	year = str(now)
	if len(set(year)) == len(year):
		print(now)
		exit()


a = int(input())
while True:
	a += 1
	if len(set(list(str(a)))) == len(str(a)):
		print(a)
		exit()


current_year = int(input())
while True:
	current_year += 1
	list_year = list(str(current_year))
	if len(list_year) == len(set(list_year)):
		print(current_year)
		break


y = input()
count = 0
while len(set(str(y))) != len(str(y)):
	x = ''.join(y)
	x = int(x)
	x += 1
	y = str(x)
	count += 1
else:
	if len(set(str(y))) == len(str(y)) and count != 0:
		print(x)
	elif len(set(str(y))) == len(str(y)) and count == 0:
		while True:
			x = ''.join(y)
			x = int(x)
			x += 1
			y = str(x)
			if len(set(str(y))) == len(str(y)):
				print(x)
				break


n = int(input())
n += 1
while 1:
	m = []
	n = str(n)
	for i in n:
		if i not in m:
			m.append(i)
	if len(m) == 4:
		print(''.join(m))
		break
	else:
		n = int(n)
		n += 1


def Distinct(n):
	a = [0] * 10
	count = 0
	while n != 0:
		b = int(n % 10)
		a[b] = 1
		n //= 10
	for i in range(10):
		if a[i] != 0:
			count += 1
	return count

def countDigit(n):
	c = 0
	while n != 0:
		r = n % 10
		c += 1
		n //= 10
	return c

def nextDistinctYear(n):
	while n:
		x = Distinct(n + 1)
		y = countDigit(n + 1)
		if x == y:
			return n + 1
		else:
			n += 1
	return -1
n = int(input())
print(nextDistinctYear(n))


bstyr = input()
flag = 0
while flag != 1:
	bstyr = str(int(bstyr) + 1)
	count = dict()
	for key in bstyr:
		count[key] = count.get(key, 0) + 1
	for item in count.values():
		if item > 1:
			flag = 0
			break
		else:
			flag = 1
print(bstyr)


def checking(year):
	f = int(year / 1000)
	s = int(year / 100 % 10)
	t = int(year / 10 % 10)
	f_d = int(year % 10)
	if f != s and f != t and (f != f_d) and (s != t) and (s != f_d) and (t != f_d):
		return True
	else:
		return False
year = int(input())
year = year + 1
while True:
	isDistinct = checking(year)
	if isDistinct == True:
		print(year)
		break
	else:
		year = year + 1


num_1 = int(input())
num = num_1 + 1
i = 0
while i == 0:
	if len(set(str(num))) == len(str(num)):
		print(num)
		i = 1
	else:
		num += 1


n = int(input()) + 1

def f(x):
	a = str(x)
	if a.count(a[0]) == 1 and a.count(a[1]) == 1 and (a.count(a[2]) == 1) and (a.count(a[3]) == 1):
		return True
	else:
		return False
while not f(str(n)):
	n += 1
print(n)


n = int(input())
i = 1
y = n + i
n = list(str(n))
while True:
	if len(n) == len(set(str(y))):
		break
	y = y + i
print(y)


def niceY(x):
	while True:
		x += 1
		if len(set(str(x))) >= 4:
			return int(x)
print(niceY(int(input())))


Input_year = input()
intano = int(Input_year) + 1
texto_ano = list(str(intano))
cont1 = texto_ano.count(texto_ano[0])
cont2 = texto_ano.count(texto_ano[1])
cont3 = texto_ano.count(texto_ano[2])
cont4 = texto_ano.count(texto_ano[3])
achou = False
while achou != True:
	if cont1 + cont2 + cont3 + cont4 == 4:
		resposta = texto_ano[0] + texto_ano[1] + texto_ano[2] + texto_ano[3]
		print(resposta)
		achou = True
	else:
		intano += 1
		texto_ano = list(str(intano))
		cont1 = texto_ano.count(texto_ano[0])
		cont2 = texto_ano.count(texto_ano[1])
		cont3 = texto_ano.count(texto_ano[2])
		cont4 = texto_ano.count(texto_ano[3])


N = int(input())
N += 1
tog = 1
while tog == 1:
	flag = 1
	temp = N
	dic = {}
	while temp != 0:
		x = temp % 10
		if x in dic:
			flag = 0
			break
		else:
			dic[x] = 1
		temp //= 10
	if flag == 1:
		print(N)
		tog = 0
	else:
		tog = 1
		N += 1


def isunique(n):
	n = str(n)
	l = list(n)
	s = set(l)
	p = list(s)
	if len(l) == len(p):
		return True
	else:
		return False
n = int(input())
n = n + 1
while True:
	if isunique(n):
		print(n)
		break
	else:
		n = n + 1


def isGood(year):
	lint = list(str(year))
	lint2 = set(lint)
	if len(lint2) == len(lint):
		return True
	else:
		return False
year = int(input()) + 1
while isGood(year) == False:
	year += 1
print(str(year))


i = int(input())
while True:
	i += 1
	foo = str(i)
	if len(set(foo)) == len(foo):
		print(i)
		break


n = input()

def by(n):
	g = set()
	while True:
		n = str(int(n) + 1)
		for i in n:
			g.add(i)
		if len(g) == 4:
			return n
		else:
			g.clear()
print(by(n))


year = int(input())
i = 1
while i >= 0:
	st = []
	su = str(year + i)
	for j in range(10):
		st.append(su.count(str(j)))
	i += 1
	if max(st) <= 1:
		print(su)
		i = -1


def isdistingt(n):
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				return 0
	return 1
s = input()
n = int(s)
while 1:
	n += 1
	if isdistingt(str(n)):
		print(n)
		break


dp = []
for i in range(1000, 9000):
	k1 = i % 10
	k2 = i // 10 % 10
	k3 = i // 100 % 10
	k4 = i // 1000
	d = {}
	d[k1] = 0
	d[k2] = 0
	d[k3] = 0
	d[k4] = 0
	if len(d) == 4:
		dp.append(i)
dp.append(9012)
y = int(input())
for i in dp:
	if i > y:
		print(i)
		break


y = int(input())

def q(i):
	i = str(i)
	w = {i[0], i[1], i[2], i[3]}
	if len(w) == 4:
		return 1
	else:
		return 0
for i in range(y + 1, 9999):
	if q(i):
		print(i)
		break


def x(a):
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		return False
	return True
ano = int(input())
ano += 1
while x(str(ano)):
	ano += 1
print(ano)


def ch(d):
	d = str(d)
	l = []
	for i in d:
		l.append(i)
	if l.count(l[0]) == 1 and l.count(l[1]) == 1 and (l.count(l[2]) == 1) and (l.count(l[3]) == 1):
		return True
	else:
		return False

def incr(x):
	x += 1
	while ch(x) == False:
		x += 1
	print(x)
x = int(input())
incr(x)


def isdistinct(year):
	year_instring = str(year)
	array = [each for each in year_instring]
	distinct = []
	for each in array:
		if not each in distinct:
			distinct.append(each)
	if len(array) == len(distinct):
		return True
	else:
		return False
year = int(input())
year += 1
while True:
	if isdistinct(year):
		break
	else:
		year += 1
		continue
print(year)


def mCheckInputs(year):
	temp = year.pop()
	if temp.isdigit() and 1000 <= int(temp) <= 9000:
		year.append(int(temp))
	else:
		exit(1)

def mHandleInputs(inputList):
	year = [input()]
	mCheckInputs(year)
	inputList.append(year[0])

def mDoWork(inputList, outputList):
	result = 0
	year = inputList[0]
	for i in range(1, pow(10, 9)):
		if isDistinct(f'{year + i}'):
			outputList.append(year + i)
			return

def isDistinct(x):
	numbersList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
	for item in numbersList:
		if x.count(str(item)) > 1:
			return False
	return True

def mReFormat(outputList):
	print(outputList[0])

def main():
	inputList = []
	mHandleInputs(inputList)
	outputList = []
	mDoWork(inputList, outputList)
	mReFormat(outputList)
main()


year = int(input())
for _ in range(10000):
	year += 1
	if list(set(str(year))).__len__() == 4:
		print(year)
		exit()


y = int(input())
y = y + 1
y = str(y)
z = int(y)
Year = True

def check(y):
	number = 0
	for i in range(len(y)):
		for j in range(len(y)):
			if y[i] == y[j]:
				number = number + 1
		if number > 1:
			return False
		number = 0
	return True
while Year == True:
	if check(y) == True:
		print(y)
		number = False
		break
	else:
		z = z + 1
		y = str(z)


def check(year):
	number = []
	for i in str(year):
		if i in number:
			return False
		else:
			number.append(i)
			continue
	return True
for i in range(int(input()) + 1, 9013):
	if check(i) == True:
		print(i)
		break
	else:
		continue


n = int(input())
i = 1
while i > 0:
	n = n + 1
	test_list = list(map(int, str(n)))
	flag = 0
	flag = len(set(test_list)) == len(test_list)
	if flag:
		print(n)
		break
	else:
		continue


import math
import cmath
from decimal import *
from fractions import *
n = int(input()) + 1
a = [0] * 4
while 1:
	a[0] = n // 1000
	a[1] = (n - a[0] * 1000) // 100
	a[2] = (n - a[0] * 1000 - a[1] * 100) // 10
	a[3] = n % 10
	(s, ok) = ([], 1)
	for i in range(4):
		if a[i] in s:
			n += 1
			ok = 0
			break
		s.append(a[i])
	if ok:
		break
print(n)


from sys import *
n = input()
i = int(n) + 1
while True:
	if sum([str(i).count(str(j)) == 1 for j in range(10)]) == len(str(i)):
		print(i)
		exit(0)
	i += 1


n = int(input())
flag = 0
while flag == 0:
	n = n + 1
	c = list(set(str(n)))
	if len(c) == 4:
		print(n)
		flag = 1


year = int(input()) + 1
while True:
	check = set()
	temp = year
	while year != 0:
		check.add(year % 10)
		year //= 10
	if len(check) == 4:
		year = temp
		break
	year = temp + 1
print(year)


T = int(input())
while T != 0:
	T += 1
	string = str(T)
	lst = list(string)
	if len(set(lst)) == len(lst):
		break
print(T)


year = int(input())
year += 1
if len(set(str(year))) == 4:
	print(year)
else:
	while len(set(str(year))) != 4:
		year += 1
	print(year)


n = int(input())
m = n + 1
while len(set(str(m))) != len(str(n)):
	m += 1
print(m)


n = int(input())
for i in range(n + 1, n + 1000):
	if len(list(str(i))) == len(set(str(i))):
		print(i)
		break


s = str(int(input()) + 1)
col = set()
flag = False
while flag == False:
	i = opn = 0
	while i < 4:
		if s[i] in col:
			opn = opn + int(s[i]) * 10 ** (3 - i) + 10 ** (3 - i)
			s = str(opn)
			col.clear()
			break
		else:
			opn = opn + int(s[i]) * 10 ** (3 - i)
			col.add(s[i])
		i += 1
		if i == 4:
			flag = True
print(s)


def check(f):
	f = str(f)
	for i in range(len(f) - 1):
		if f[i] in f[i + 1:]:
			return False
	return True
x = int(input())
x = x + 1
while True:
	if check(x):
		print(x)
		break
	else:
		x = x + 1


entrada = int(input())
while True:
	entrada += 1
	boolean2 = False
	for e in range(len(str(entrada))):
		for k in range(len(str(entrada))):
			if e != k and str(entrada)[e] == str(entrada)[k]:
				boolean2 = True
	if not boolean2:
		break
print(entrada)


n = input()
n = str(int(n) + 1)
while sorted(list(set(n))) != sorted(list(n)):
	if sorted(list(set(n))) == sorted(list(n)):
		break
	n = str(int(n) + 1)
if sorted(list(set(n))) == sorted(list(n)):
	print(n)


def isDistinct(n):
	n = str(n)
	n = list(map(int, n))
	m = set(n)
	if len(n) == len(m):
		return True
	else:
		return False
n = int(input())
i = n + 1
while not isDistinct(i):
	i += 1
print(i)


gy = int(input())
by = str(gy + 1)
while by.count(by[0]) > 1 or by.count(by[1]) > 1 or by.count(by[2]) > 1 or (by.count(by[3]) > 1):
	by = str(int(by) + 1)
print(by)


n = int(input())
r = n + 1
while True:
	if len(list(str(n))) == len(set(list(str(r)))):
		break
	else:
		r += 1
print(r)


n = int(input())
j = n + 1
while j > n:
	i = 4
	temp = j
	digit = []
	while i > 0:
		digit.append(temp % 10)
		temp = temp // 10
		i -= 1
	if len(digit) == len(set(digit)):
		print(j)
		break
	j += 1


year = int(input())
while True:
	year = year + 1
	year = str(year)
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]):
		if year[1] != year[2] and year[1] != year[3]:
			if year[2] != year[3]:
				print(year)
				break
	year = int(year)


def freq(string):
	h = {}
	for x in string:
		if x in h:
			h[x] += 1
		else:
			h[x] = 1
	return h

def is_distinct(y):
	h = freq(str(y))
	aa = lambda x: x == 1
	return all(map(aa, [h[x] for x in h]))
y = int(input())
y += 1
while not is_distinct(y):
	y += 1
print(y)


n = str(int(input()) + 1)
k = list(n)
while k.count(n[0]) > 1 or k.count(n[1]) > 1 or k.count(n[2]) > 1:
	n = str(int(n) + 1)
	k = list(n)
print(n)


def solution(n):
	s = 0
	for i in range(1, 100000000):
		s = n + i
		x = str(s)
		if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
			break
		else:
			continue
	return x
year = int(input())
ans = solution(year)
print(ans)


y = int(input())
while True:
	y += 1
	c = set(str(y))
	clen = len(c)
	ylen = len(str(y))
	if clen == ylen:
		print(y)
		break


def cnt(n):
	a = [0] * 10
	c = 0
	b = 0
	while n != 0:
		a[n % 10] += 1
		if a[n % 10] == 1:
			c += 1
		n //= 10
		b += 1
	if b == c:
		return True
	else:
		return False
n = int(input().strip())
i = 1
while not cnt(n + i):
	i += 1
print(n + i)


y = int(input(''))
minY = max(1000, y)
maxY = 9999
for i in range(y + 1, maxY):
	s = set(str(i))
	if len(s) == 4:
		print(i)
		break


n = int(input())
for i in range(n + 1, 9013):
	a = str(i)
	A = []
	for j in a:
		A.append(j)
	A = set(A)
	if len(A) == len(a):
		print(i)
		break


year = int(input())
for i in range(year + 1, 9050):
	if len(set(str(i))) == 4:
		year = i
		break
print(year)


def diff(n):
	s = set(n)
	if len(s) == len(n):
		return 1
	else:
		return 0
n = int(input()) + 1
while 1:
	if diff(str(n)) == 1:
		print(n)
		break
	else:
		n = int(n) + 1


n = int(input())
k = 0
ar = []
for i in range(1, 2 * n):
	k = n + i
	m = str(k)
	if len(str(k)) == len(set(str(k))):
		print(k)
		break


s = input()
for i in range(int(s) + 1, 9013):
	t = str(i)
	q = [t[0], t[1], t[2], t[3]]
	q.sort()
	if q[0] < q[1] < q[2] < q[3]:
		print(i)
		break


import sys
try:
	sys.stdin = open('inputs.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
finally:
	input = sys.stdin.readline
	print = sys.stdout.write
year1 = int(input())
year2 = year1 + 1

def next_unq(year):
	count = set()
	for (j, i) in enumerate(year):
		if i in count:
			break
		else:
			count.add(i)
	else:
		return year
	year = str(int(year) // 10 ** (3 - j) * 10 ** (3 - j) + 10 ** (3 - j))
	return next_unq(year)
print(next_unq(str(year2)))


import sys
y = int(input())
while True:
	y += 1
	if y == 1986:
		print('2013')
		sys.exit()
	else:
		s = set(list(str(y)))
		if len(s) == 4:
			print(y)
			sys.exit()


input_number = input()
number = int(input_number)
number += 1

def digits(n):
	return [int(x) for x in str(n)]

def distinct_digits(number):
	digs = digits(number)
	if digs[0] != digs[1] and digs[2] != digs[1] and (digs[2] != digs[3]) and (digs[3] != digs[0]) and (digs[0] != digs[2]) and (digs[1] != digs[3]):
		return 0
	else:
		return 1
while distinct_digits(number) == 1:
	number += 1
print(number)


def check(n):
	a = str(n)[0]
	b = str(n)[1]
	c = str(n)[2]
	d = str(n)[3]
	if a != b and b != c and (c != d) and (d != a) and (b != d) and (a != c):
		return 0
	else:
		return 1
n = int(input())
n += 1
while check(n):
	n += 1
print(n)


def unique(i):
	for l in range(len(i)):
		for val in i[:l] + i[l + 1:]:
			if val == i[l]:
				return False
	return True
i = input()
while True:
	i = str(int(i) + 1)
	if unique(i):
		break
print(i)


a = int(input(''))
while 1:
	a += 1
	c = str(a)
	b = [j for j in c]
	b = set(b)
	if len(b) == 4:
		print(a)
		break


y = int(input())
i = 1
while True:
	str1 = str(y + i)
	if str1[0] != str1[1] and str1[0] != str1[2] and (str1[0] != str1[3]) and (str1[1] != str1[2]) and (str1[1] != str1[3]) and (str1[2] != str1[3]):
		print(str1)
		break
	i += 1


n = int(input())
for i in range(n + 1, 10001):
	a = str(i)
	b = list(a)
	c = b[0]
	d = b[1]
	e = b[2]
	f = b[3]
	if c != d and c != e and (c != f) and (d != e) and (d != f) and (e != f):
		print(i)
		break


entry = int(input())
i = entry + 1
while i > entry:
	if len(set(str(i))) == 4:
		print(i)
		break
	else:
		i += 1


c = int(input())
c += 1
while len(set(list(str(c)))) < 4:
	c += 1
print(c)


year = int(input())
found = False
while not found:
	year += 1
	a = int(divmod(year, 1000)[0])
	b = divmod(divmod(year, 100)[0], 10)[1]
	c = divmod(divmod(year, 10)[0], 10)[1]
	d = int(divmod(year, 10)[1])
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(int(year))


year = int(input()) + 1

def year_has_distinct_digits(year):
	year = str(year)
	s = ''
	for i in year:
		if i not in s:
			s += i
	if len(s) == len(year):
		return True
	else:
		return False
while year_has_distinct_digits(year) != True:
	year += 1
else:
	print(year)


def beauty(x):
	l1 = len(str(x))
	x = set([i for i in str(x)])
	if len(x) == l1:
		return True
	else:
		return False
n = int(input()) + 1
while not beauty(n):
	n += 1
print(n)


x = int(input())
for i in range(x + 1, 10000):
	k = list(set(str(i)))
	if len(k) == 4:
		print(i)
		exit()


yeargiv = input()
yearwanted = int(yeargiv) + 1
while len(set(str(yearwanted))) != len(str(yearwanted)):
	yearwanted += 1
print(yearwanted)


def check():
	digits = list(str(year))
	for i in range(4):
		for j in range(i + 1, 4):
			if digits[i] == digits[j]:
				return False
	return True
year = int(input())
year += 1
while not check():
	year += 1
print(year)


def isdis(n):
	f = n % 10
	n = int(n / 10)
	ff = n % 10
	n = int(n / 10)
	fff = n % 10
	n = int(n / 10)
	ffff = n % 10
	q = set([f, ff, fff, ffff])
	if len(q) == 4:
		return True
	else:
		return False
n = int(input())
n = n + 1
while not isdis(n):
	n = n + 1
print(n)


n = int(input())
i = n + 1
while i > n:
	k = str(i)
	cnt = 0
	for j in k:
		if k.count(j) == 1:
			cnt += 1
	if cnt == 4:
		print(i)
		break
	i += 1


y = int(input())

def d(y):
	a = str(y)
	b = set(a)
	if len(a) == len(b):
		return 1
	else:
		return 0
for i in range(y + 1, 9013):
	if d(i) == 1:
		break
print(i)


y = int(input())
print([i for i in range(y + 1, 10000) if len(set(str(i))) == 4][0])


a = int(input()) + 1
for i in range(1000):
	for p in str(a):
		if str(a).count(p) > 1:
			a += 1
print(a)


input_year = int(input())
i = input_year
result = 'NO'
while i <= 10000 and input_year >= 1000 and (result == 'NO'):
	i += 1
	str_year = str(i)
	result = 'YES'
	j = 0
	while j < len(str_year) - 1 and result != 'NO':
		k = j + 1
		while k < len(str_year) and result != 'NO':
			if str_year[j] == str_year[k]:
				result = 'NO'
			k += 1
		j += 1
print(i)


y = int(input())
y += 1
k = str(y)
b = k[0] != k[1] and k[0] != k[2] and (k[0] != k[3]) and (k[1] != k[2]) and (k[1] != k[3]) and (k[2] != k[3])
while not b:
	y += 1
	k = str(y)
	b = k[0] != k[1] and k[0] != k[2] and (k[0] != k[3]) and (k[1] != k[2]) and (k[1] != k[3]) and (k[2] != k[3])
print(y)


s = input().strip()
r = int(''.join(s))
r += 1
r = str(r)
ind = []
while 1 < 2:
	for i in range(10):
		ind.append(0)
	flag = 0
	s = r
	for i in range(len(s)):
		ind[int(s[i]) - 1] += 1
	for i in range(len(ind)):
		if ind[i] > 1:
			flag = 1
	ind = []
	if flag == 0:
		print(r)
		break
	else:
		r = int(r)
		r += 1
		r = str(r)


n = int(input())
while 1:
	n += 1
	a = n
	d = {}
	f = 1
	while a > 0:
		r = a % 10
		d[r] = d.get(r, 0) + 1
		a //= 10
	for i in d.keys():
		if d[i] > 1:
			f = 0
			break
	if f == 1:
		break
print(n)


y = input()
y = str(int(y) + 1)
while y[0] in y[1:] or y[1] in y[2:] or y[2] == y[3]:
	y = str(int(y) + 1)
print(y)


year = int(input())
year_set = set()
year_len = 0
while year_len != 4:
	for i in str(year + 1):
		year_set.update(i)
	year_len = len(year_set)
	year += 1
	year_set.clear()
print(year)


n = int(input())
(a, b, c, d) = (0, 0, 0, 0)
k = 0
while True:
	n += 1
	k = n
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000 % 10
	if a != b and b != c and (c != d) and (a != c) and (a != d) and (b != d):
		break
print(k)


n = int(input())
while 1:
	flag = 0
	n += 1
	i = list(str(n))
	v1 = -1
	while v1 < 3:
		v1 += 1
		v2 = v1 + 1
		while v2 < 4:
			if i[v1] == i[v2]:
				flag = 1
				break
			v2 += 1
		if flag == 1:
			break
	if flag == 0:
		break
print(n)


s = int(input())
while True:
	s += 1
	li = [ch for ch in str(s)]
	se = {ch for ch in str(s)}
	if len(li) == len(se):
		break
print(s)


y = int(input())
found = True
while found:
	y += 1
	if len(list(str(y))) == len(set(list(str(y)))):
		print(y)
		found = False


a = int(input())
b = str(a)
x = 0
while x == 0:
	a += 1
	c = str(a)
	if c.count(c[0]) == 1 and c.count(c[1]) == 1 and (c.count(c[2]) == 1) and (c.count(c[3]) == 1):
		print(a)
		x = 1


n = int(input())
for i in range(n + 1, 9015):
	l = str(i)
	if len(list(l)) == len(set(l)):
		print(i)
		break


q = int(input())
while True:
	w = True
	q += 1
	e = str(q)
	for i in e:
		if e.count(i) != 1:
			w = False
	if w:
		break
print(e)


y = input()
a = int(y)
for i in range(a + 1, 9050):
	if len(set(list(str(i)))) == 4:
		print(i)
		break


n = str(int(input()) + 1)
while n.count(n[0]) > 1 or n.count(n[1]) > 1 or n.count(n[2]) > 1 or (n.count(n[3]) > 1):
	n = str(int(n) + 1)
print(n)


def beautiful(n):
	n = list(str(n))
	cnt = []
	for _ in range(0, 10):
		cnt.append(0)
	for c in n:
		cnt[int(c)] += 1
	r = 1
	for i in range(0, 10):
		if cnt[i] > 1:
			r = 0
			break
	return r
year = int(input())
ans = year + 1
while True:
	if beautiful(ans):
		print(ans)
		break
	ans += 1


t1 = int(input())
s1 = str(t1)
s1 = set(list(s1))
t2 = t1 + 1
while t2 < 10000:
	s2 = str(t2)
	s2 = set(list(s2))
	if len(s2) == 4:
		print(t2)
		break
	t2 = t2 + 1


n = int(input())
i = 0
while i != 1:
	n = n + 1
	a = n
	while a != 0:
		s1 = a % 10
		a = a // 10
		s2 = a % 10
		a = a // 10
		s3 = a % 10
		a = a // 10
		if a != s1 and a != s2 and (a != s3) and (s1 != s2) and (s1 != s3) and (s2 != s3):
			i = 1
print(n)


b = int(input()) + 1
while len(str(b)) != len(set(str(b))):
	b += 1
print(b)


years = list(range(1000, 9013))
given = int(input())
for x in years:
	if len(set(str(x))) == 4 and x > given:
		print(x)
		break


n = int(input())
a = ''
while True:
	n += 1
	n_str = str(n)
	a = ''
	for i in range(4):
		a += n_str[i] + ' '
	a = set(a.split())
	if len(a) == 4:
		print(n)
		break


from collections import Counter
n = int(input())
n1 = n + 1
while True:
	s = list(str(n1))
	c = Counter(s)
	if len(c) == len(s):
		print(''.join(s))
		break
	n1 = n1 + 1


def isRaz(n):
	sn = set(str(n))
	return len(sn) == len(str(n))
n = int(input())
i = n + 1
while True:
	if isRaz(i):
		print(i)
		break
	i += 1


def f(s):
	for i in range(4):
		for j in range(i + 1, 4):
			if s[i] == s[j]:
				return 0
	return 1
k = int(input())
p = 0
while p != 1:
	k += 1
	s = str(k)
	if f(s) == 1:
		p = 1
		break
print(k)


def isBeautiful(n):
	n = str(n)
	l = {i for i in n}
	return len(n) == len(l)
n = int(input())
ans = n + 1
while not isBeautiful(ans):
	ans += 1
print(ans)


def is_duplicate(y):
	digits = set()
	while y:
		digits.add(y % 10)
		y = y // 10
	return True if len(digits) == 4 else False

def find_next_beautiful_year(y):
	while True:
		if is_duplicate(y):
			return y
		y += 1
year = int(input())
print(find_next_beautiful_year(year + 1))


n = int(input()) + 1
while len(list(str(n))) != len(list(set(list(str(n))))):
	n += 1
print(n)


def buscar(n):
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		x = True
	else:
		x = False
	return x
n = int(input())
k = n + 1
while k < 9887:
	a = buscar(k)
	if a == True:
		x = k
		break
	k += 1
print(x)


n = int(input())
for i in range(n + 1, 9999):
	s = str(i)
	freq = {}
	for j in s:
		if j in freq:
			break
		else:
			freq[j] = 1
	else:
		print(i)
		break
	continue


def solve(year):
	while True:
		year = str(int(year) + 1)
		if len(set(year)) == 4:
			return year
ans = solve(int(input()))
print(ans)


y = int(input())
while True:
	y += 1
	if sorted([x for x in str(y)]) == sorted(list(set([x for x in str(y)]))):
		print(y)
		break


x = int(input())
y = list(str(x))
result = 0
for i in range(x + 1, 9013):
	count = 0
	lst = list(str(i))
	for j in range(4):
		for k in range(j + 1, 4):
			if lst[j] == lst[k]:
				count = 1
	if count == 0:
		result = ''.join(lst)
		break
print(result)


y = int(input())
while True:
	y += 1
	x = str(y)
	a = x[0]
	b = x[1]
	c = x[2]
	d = x[3]
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(y)


a = input()
while True:
	s = int(a) + 1
	a = str(s)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]):
		if a[1] != a[2] and a[1] != a[3]:
			if a[2] != a[3]:
				break
print(a)


n = int(input())
while not 1000 <= n <= 9000:
	n = int(input())
a = n + 1
a = str(a)
s = set(a)
while len(a) != len(s):
	a = int(a)
	a += 1
	a = str(a)
	s = set(a)
print(a)


a = str(input())
a = int(a)
a = a + 1
a = str(a)
b = 0
while b == 0:
	i = 0
	b = 1
	while i < len(str(a)):
		j = i + 1
		while j < len(str(a)):
			if a[i] == a[j]:
				b = 0
				a = int(a)
				a = a + 1
				a = str(a)
				break
			j += 1
		i += 1
print(a)


n = int(input())

def search(n):
	while True:
		n += 1
		s = str(n)
		if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
			return n
print(search(n))


y = int(input())

def fn(y):
	while True:
		(s, c) = ('0123456789', 0)
		for i in str(y + 1):
			if i in s:
				c += 1
				s = s.replace(i, '')
		if c == len(str(y + 1)):
			return y + 1
		else:
			y += 1
print(fn(y))


from collections import Counter
y = int(input())
for i in range(y + 1, 10000):
	if len(Counter(str(i))) == 4:
		print(i)
		break


start = int(input())
year = start + 1
while year > start:
	year_digits = set(str(year))
	if len(year_digits) == 4:
		print(year)
		break
	year += 1


def year():
	number = int(input())
	while True:
		number = number + 1
		a = str(number)
		b = set(a)
		if len(a) == len(b):
			return number
			break
		else:
			continue
print(year())


n = int(input()) + 1
while 1:
	l = list(map(int, str(n)))
	p = set(l)
	if len(p) == 4:
		print(n)
		break
	n = n + 1


def isAllUnique(n):
	n = list(str(n))
	if n[0] == n[1] or n[0] == n[2] or n[0] == n[3] or (n[1] == n[2]) or (n[1] == n[3]) or (n[2] == n[3]):
		return False
	return True
n = int(input())
while True:
	n += 1
	if isAllUnique(n):
		print(n)
		break


def isbeautiful(n):
	i = n % 10
	j = int(n / 10) % 10
	k = int(n / 100) % 10
	l = int(n / 1000) % 10
	if i != j and j != k and (k != l) and (i != k) and (i != l) and (j != l):
		return 1
	else:
		return 0

def main():
	n = int(input())
	for i in range(n + 1, 9020):
		res = isbeautiful(i)
		if res == 1:
			print(i)
			break
main()


s = int(input())
s += 1
t = True
while t:
	s = list(map(int, str(s)))
	if s[0] == s[1] or s[0] == s[2] or s[0] == s[3] or (s[1] == s[2]) or (s[1] == s[3]) or (s[2] == s[3]):
		s = int(''.join(map(str, s)))
		s += 1
	else:
		t = False
		s = int(''.join(map(str, s)))
print(s)


def BeautifulYear():
	y = int(input())
	y2 = [i for i in str(y + 1)]
	while len(set(y2)) != len(y2):
		tmp = int(''.join(y2)) + 1
		y2 = [i for i in str(tmp)]
	print(int(''.join(y2)))

def main():
	BeautifulYear()
main()


n = int(input()) + 1
s = {}
while True:
	s = set(list(str(n)))
	if len(s) == 4:
		break
	elif len(s) > 4:
		break
	n += 1
print(n)


from sys import stdin
year = stdin.readline().rstrip()
year = int(year)

def findGreaterDistinctYear(year):
	year += 1
	while len(set(list(str(year)))) < 4:
		year += 1
	return year
print(findGreaterDistinctYear(year))


a = int(input())
while True:
	a += 1
	b = str(a)
	if len(set(b)) == 4:
		print(b)
		exit()


y = int(input())
while 1 > 0:
	y = y + 1
	x = []
	z = str(y)
	for i in range(4):
		x.append(z[i])
	if len(set(x)) == 4:
		break
print(''.join(x))


year = int(input())

def areDifferent(year):
	year = str(year)
	y = []
	for i in year:
		if i not in y:
			y.append(i)
	if len(y) == 4:
		return True
	else:
		return False
for i in range(year + 1, 10000):
	if areDifferent(i):
		break
print(i)


a = int(input())
c = []
for i in range(1000, 9999):
	if str(i)[0] != str(i)[1] and str(i)[0] != str(i)[2] and (str(i)[0] != str(i)[3]) and (str(i)[1] != str(i)[2]) and (str(i)[1] != str(i)[3]) and (str(i)[2] != str(i)[3]):
		c.append(i)
if a in c:
	t = c.index(a)
	print(c[t + 1])
if a not in c:
	for i in range(0, len(c)):
		if a < c[i]:
			print(c[i])
			break


n = int(input())
a = set()
copy = 0
for i in range(n + 1, 100000):
	copy = i
	while i != 0:
		a.add(i % 10)
		i = i // 10
	if len(a) == 4:
		print(copy)
		break
	else:
		a.clear()


numb = int(input())
result = ''
for i in range(numb + 1, 10000):
	list1 = list(str(i))
	list2 = set(list1)
	if len(list1) == len(list2):
		for i in list1:
			result += str(i)
		break
result = int(result)
print(result)


s = input()
for i in range(8000):
	s = str(int(s) + 1)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		break


year = int(input())
string = ''
while True:
	year += 1
	string = str(year)
	if string[0] not in string[1:] and string[1] not in string[2:] and (string[2] not in string[3:]):
		print(year)
		break


a = int(input()) + 1
while len(str(a)) != len(set(str(a))):
	a = a + 1
else:
	print(a)


def dup_c(n):
	b = str(n)
	i = 0
	for x in b:
		if b.count(x) < 2:
			i = i + 1
	if i == 4:
		return True
	else:
		return False
a = input()
b = int(a)
for x in range(b + 1, 90000):
	if dup_c(x) == True:
		print(x)
		break


y = input()
y1 = int(y)
y2 = y1
while True:
	if y2 > y1 and len(set(str(y2))) == 4:
		break
	y2 += 1
print(y2)


year = int(input())
distinct = False
while distinct == False:
	res = []
	year += 1
	for i in str(year):
		res.append(i)
	temp = set(res)
	if len(temp) == 4:
		distinct = True
print(year)


y = int(input())
i = y + 1
while i > y:
	if len(set(str(i))) == 4:
		print(i)
		i = 0
	else:
		i = i + 1


y = str(int(input()) + 1)
flag = False
while flag != True:
	x = set(y)
	if len(x) == 4:
		flag = True
		print(y)
	else:
		y = str(int(y) + 1)


a = int(input())
a = a + 1
sw = True
while sw:
	le = len(str(a))
	seto = set(str(a))
	if le == len(seto):
		sw = False
	else:
		a = a + 1
print(a)


n = int(input())
s = {}
while len(s) != 4:
	n += 1
	l = [n % 10 ** (i + 1) // 10 ** i for i in range(4)]
	s = set(l)
print(n)


from collections import Counter
year = int(input())
next_year = year + 1
c = Counter(str(next_year))
while len(c) != 4:
	next_year += 1
	c = Counter(str(next_year))
print(next_year)


def distinct(n):
	flag = 0
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				flag = 1
	return flag
n = int(input())
n = n + 1
n = str(n)
n = list(n)
while distinct(n) == 1:
	d = ''.join(n)
	d = int(d)
	d = d + 1
	d = str(d)
	n = list(d)
print(''.join(n))


year = int(input())
done = False
for x in range(year // 1000, 10):
	for y in range(10):
		for z in range(10):
			for a in range(10):
				if not done and x != y and (x != z) and (x != a):
					if y != z and y != a:
						if z != a:
							if 1000 * x + 100 * y + 10 * z + a > year:
								print(1000 * x + 100 * y + 10 * z + a)
								done = True


n = int(input())
m = str(n + 1)
j = 2
while True:
	k = 0
	if m[0] == m[1] or m[0] == m[2] or m[0] == m[3] or (m[1] == m[2]) or (m[3] == m[1]) or (m[2] == m[3]):
		k += 1
	if k != 0:
		m = str(n + j)
		j = j + 1
	else:
		break
print(int(m))


def _271A(year):
	while True:
		year += 1
		if len(list(set(str(year)))) == 4:
			return year
print(_271A(int(input())))


n = int(input())
while True:
	n += 1
	i1 = i = str(n)
	if i[0] != i[1] and i[0] != i[2] and (i[0] != i[3]) and (i[1] != i[2]) and (i[1] != i[3]) and (i[2] != i[3]):
		print(i1)
		break


x = input()
for i in range(int(x) + 1, 9013):
	y = set(str(i))
	if len(y) == 4:
		print(i)
		break


n = int(input())
for i in range(n + 1, 10000):
	s = list(str(i))
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(int(i))
		exit(0)


s = int(input())
result = 0
for i in range(s + 1, 10000):
	d = 0
	result = list(str(i))
	result.sort()
	for j in range(0, 3):
		if result[j] == result[j + 1]:
			break
		else:
			d = d + 1
	if d == 3:
		print(i)
		break


x = int(input())

def repition(num):
	z = list(str(num))
	y = set(z)
	return len(z) is len(y)
for i in range(int(x) + 1, 10001):
	if repition(i) == True:
		print(i)
		break


def year(yr):
	b = str(int(yr) + 1)
	arr = list((char for char in b))
	if arr.count(arr[0]) == 1 and arr.count(arr[1]) == 1 and (arr.count(arr[2]) == 1) and (arr.count(arr[3]) == 1):
		return b
	else:
		return year(b)
n = input()
print(year(n))


n = int(input())
for i in range(1, 1000):
	x = n + i
	l1 = list(str(x))
	l2 = set(l1)
	if len(l2) == len(l1):
		print(x)
		break


def read_str():
	return input()

def read_int():
	return int(input())

def read_str_array():
	return [str(i) for i in input().split()]

def read_int_array():
	return [int(i) for i in input().split()]

def is_true(st):
	map = {}
	for i in st:
		if i not in map:
			map[i] = 'DD'
		else:
			return False
	return True

def solve(s1):
	k = s1
	while is_true(str(k)) == False or k == s1:
		k += 1
	return k
N = read_int()
ans = solve(N)
print(ans)


n = int(input())
t = 0
n += 1
while t != 1:
	if len(set((int(i) for i in str(n)))) == 4:
		print(n)
		t = 1
	n += 1


from sys import stdin
n = int(stdin.readline().strip())
n += 1
temp = list(str(n))
while True:
	if len(list(set(temp))) == len(temp):
		print(n)
		break
	else:
		n += 1
		temp = list(str(n))


def isDistinct(x):
	l = list(str(x))
	s = set(l)
	return True if len(l) == len(s) else False
n = int(input())
i = n + 1
while True:
	if isDistinct(i) is True:
		break
	i += 1
print(i)


def notEqual(s):
	counts = {}
	for i in s:
		counts[i] = counts.setdefault(i, 0) + 1
	for x in counts.values():
		if x >= 2:
			return True
	return False
year = input()
year = str(int(year) + 1)
while notEqual(year):
	year = str(int(year) + 1)
print(year)


a = int(input())
b = 1
while True:
	a = a + b
	a = str(a)
	if a.count(a[0]) == 1 and a.count(a[1]) == 1 and (a.count(a[2]) == 1) and (a.count(a[3]) == 1):
		print(a)
		break
	else:
		a = int(a)


a = int(input())
b = list(map(int, *str(a + 1).split()))

def seet(v):
	c = []
	for i in range(len(v)):
		if v[i] not in c:
			c.append(v[i])
	return c
while seet(b) != b:
	a += 1
	b = list(map(int, *str(a).split()))
print(*b, sep='')


def ddy(x):
	a = 1
	x = str(x)
	for i in range(10):
		i = str(i)
		a = 2 * a * (int(x.count(i)) - 0.5)
	if abs(a) == 1:
		return 1
	else:
		return 0
b = int(input())
for i in range(b + 1, b + 105):
	if ddy(i) == 1:
		print(i)
		break


year = input()

def check(year):
	arr = [False for i in range(10)]
	for i in range(len(year)):
		if arr[ord(year[i]) - ord('0')] is True:
			return False
		else:
			arr[ord(year[i]) - ord('0')] = True
	return True
i = int(year) + 1
while True:
	if check(str(i)) is True:
		print(i)
		break
	else:
		i += 1


import re
year = input()
i = True
while i:
	year = str(int(year) + 1)
	new_year = int(year)
	a3 = str(new_year % 10)
	new_year = int(new_year / 10)
	if not re.search(a3, str(new_year)):
		a2 = str(new_year % 10)
		new_year = int(new_year / 10)
		if not re.search(a2, str(new_year)):
			a1 = str(new_year % 10)
			new_year = int(new_year / 10)
			if not re.search(a1, str(new_year)):
				break
print(year)


a = 4
n = input()
x = int(n)
for i in range(x + 1, 9013):
	s = str(i)
	ss = set(s)
	if len(ss) == a:
		main = i
		break
print(main)


def check_year(year):
	year = str(year)
	unique_digits = []
	for digit in year:
		if digit not in unique_digits:
			unique_digits.append(digit)
	if len(unique_digits) == 4:
		return True
	else:
		return False
year = int(input()) + 1
while True:
	if check_year(year):
		print(year)
		break
	year += 1


def check_unique(year: int):
	xs = [0] * 4
	for i in range(4):
		xs[i] = year // 10 ** (3 - i)
		year = year % 10 ** (3 - i)
	find = {}
	for digit in xs:
		if find.get(digit, 0):
			return False
		find[digit] = 1
	return True

def next_unique_year(year: int):
	year += 1
	while not check_unique(year):
		year += 1
	return year
n = int(input())
print(next_unique_year(n))


n = input()
a = int(n)
for i in range(a + 1, a + 1000):
	b = str(i)
	c = ''.join(set(b))
	if len(c) == 4:
		print(b)
		break


s = int(input())
while 1:
	flag = 0
	s += 1
	u = str(s)
	for i in range(len(u)):
		for j in range(i + 1, len(u)):
			if u[i] == u[j]:
				flag = 1
				break
	if flag == 0:
		print(s)
		break


a = int(input())
a += 1
b = list(str(a))
while len(b) != len(set(b)):
	a += 1
	b = list(str(a))
print(a)


start = int(input())
check = 0
while check == 0:
	start = start + 1
	if len(list(str(start))) == len(set(list(str(start)))):
		check = 1
print(start)


n = int(input())
for i in range(0, 10000000, 1):
	n += 1
	if str(n)[0] != str(n)[1] and str(n)[0] != str(n)[2] and (str(n)[0] != str(n)[3]) and (str(n)[1] != str(n)[2]) and (str(n)[1] != str(n)[3]) and (str(n)[2] != str(n)[3]):
		print(n)
		break


year = str(int(input()) + 1)
while len(list(year)) != len(set(year)):
	year = str(int(year) + 1)
print(year)


g = int(input())
b = str(g + 1)
while b.count(b[0]) > 1 or b.count(b[1]) > 1 or b.count(b[2]) > 1 or (b.count(b[3]) > 1):
	b = str(int(b) + 1)
print(b)


s = int(input())
for i in range(s + 1, s + 2000):
	l = []
	c = str(i)
	for j in c:
		if j not in l:
			l.append(j)
	ans = ''.join(l)
	if int(ans) > int(s):
		break
print(ans)


n = int(input())
x = n + 1
y = x
while x > n:
	l = []
	while x != 0:
		if x % 10 not in l:
			l.append(x % 10)
			x = x // 10
		else:
			y = y + 1
			x = y
			break
	if len(l) == 4:
		print(y)
		break
	l.clear()


y = int(input())
a = 0
b = 0
c = 0
d = 0
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	y += 1
	a = int(y % 10)
	b = int(y % 100 / 10)
	c = int(y / 100 % 10)
	d = int(y / 1000)
print(y)


def distinct(x):
	log = [False] * 10
	while x > 0:
		digit = x % 10
		if log[digit]:
			return False
		x = x // 10
		log[digit] = True
	return True
y = int(input())
y += 1
while not distinct(y):
	y += 1
print(y)


n = input()
temp = n
while True:
	temp = str(int(temp) + 1)
	li = []
	for i in temp:
		li.append(i)
	if len(set(li)) == len(li):
		break
print(temp)


def all_different(num):
	nums = set(num)
	return num.__len__() == nums.__len__()

def calculate(num):
	while True:
		if all_different(str(num + 1)):
			return num + 1
		num += 1
n = int(input())
print(calculate(n))


def diff_digits(year):
	year_check = str(year)
	check_list = []
	for n in year_check:
		if n not in check_list:
			check_list.append(n)
		else:
			return False
	return True
year = int(input())
counter = 0
while not diff_digits(year) or counter == 0:
	counter = 1
	year += 1
print(year)


a = int(input())
a = a + 1
while str(a)[0] == str(a)[1] or str(a)[0] == str(a)[2] or str(a)[0] == str(a)[3] or (str(a)[1] == str(a)[2]) or (str(a)[1] == str(a)[3]) or (str(a)[2] == str(a)[3]):
	a += 1
else:
	print(a)


t = int(input())

def diff_digits(n):
	p = []
	while n > 0:
		k = n % 10
		n = n // 10
		p.append(k)
	flag = 1
	for i in range(4):
		for j in range(4):
			if p[i] == p[j] and i != j:
				flag = 0
				break
	return flag
h = 0
i = t + 1
while h != True:
	h = diff_digits(i)
	i += 1
print(i - 1)


num = input()
for i in range(int(num) + 1, 9100):
	s = list(set(str(i)))
	if len(s) == 4:
		print(i)
		break
	else:
		continue


n = int(input())
a = 1
while a:
	n = n + 1
	a = n % 1000 % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(n)
		a = 0
	else:
		a = 1


y = input()
needed = 0
flg = True
i = int(y) + 1
while True:
	k = str(i)
	for j in range(len(k)):
		flg = True
		if k.count(k[j]) > 1:
			flg = False
			break
	if flg == True:
		needed = int(k)
		break
	i += 1
print(needed)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s - 1)])

def invr():
	return map(int, input().split())

def checkSame(s):
	return not len(set(s)) == len(s)
n = int(input()) + 1
while checkSame(str(n)):
	n += 1
print(n)


def isBeautifulYear(y):
	digit = list(str(y))
	arr = []
	for x in digit:
		if x not in arr:
			arr.append(x)
		else:
			return False
	return True
y = int(input())
x = y + 1
while isBeautifulYear(x) == False:
	x += 1
print(x)


a = int(input())
a += 1
while True:
	one = a % 10
	two = a // 10 % 10
	three = a // 100 % 10
	four = a // 1000
	if one != two and two != three and (three != four) and (two != four) and (one != four) and (one != three):
		print(a)
		break
	a += 1


n = int(input())
while True:
	n += 1
	k = str(n)
	f = 1
	j = 0
	while j != len(k) - 1:
		if k[j] in k[j + 1:]:
			f = 0
			break
		else:
			j += 1
	if f == 1:
		break
print(n)


def check(x):
	return len(set(str(x))) == len(str(x))
y = int(input()) + 1
while check(y) == 0:
	y += 1
print(y)


year = int(input())
y = year + 1
count = dict()
yr = y
while yr > year:
	while y > 0:
		r = y % 10
		y //= 10
		if r not in count.keys():
			count[r] = 1
		else:
			count[r] += 1
	y = yr + 1
	if len(count.keys()) == 4:
		break
	yr += 1
	count.clear()
print(yr)


n = int(input())
y = n + 1
while n > 0:
	list1 = []
	list2 = []
	k = str(y)
	for i in k:
		list1.append(i)
	for i in list1:
		if i not in list2:
			list2.append(i)
	if len(list1) == len(list2):
		break
	else:
		y = y + 1
print(y)


n = int(input())
q = n + 1
c = 0
while n > 0:
	j = str(q)
	d = 0
	for i in j:
		c = j.count(i)
		if c == 1:
			d = d + 1
	q = q + 1
	if d == len(j):
		print(int(j))
		break


year = int(input())
year = year + 1
y_list = []
ans = 'paini'
while ans == 'paini':
	year_str_list = [i for i in str(year)]
	yset = set(year_str_list)
	if len(yset) >= 4:
		ans = 'paisi'
		print(year)
	year += 1


n = input()
(k, a) = (0, str(int(n) + 1))
while True:
	for i in range(len(a)):
		if a.count(a[i]) >= 2:
			k += 1
	if k == 0:
		print(a)
		break
	(k, a) = (0, str(int(a) + 1))


year = int(input()) + 1

def digits(n):
	if n < 10:
		return set([n])
	else:
		return digits(n // 10).union(set([n % 10]))
while len(digits(year)) != 4:
	year += 1
print(year)


n = input()
n = int(n)
n = n + 1
while 1:
	lst = []
	n = str(n)
	for i in n:
		lst.append(i)
	s = set(lst)
	n = int(n)
	if len(lst) == len(s):
		print(n)
		break
	else:
		n = n + 1


jahr = input()
k = 0
while k != 1:
	jahr = int(jahr) + 1
	jahr = str(jahr)
	jahrlist1 = list(jahr)
	jahrlist2 = list(jahr)
	i = 0
	count = 0
	while i < len(jahr):
		jahrlist2[i] = 'X'
		if jahrlist1[i] in jahrlist2:
			i = len(jahr)
		else:
			count += 1
		i += 1
	if count > len(jahr) - 1:
		k = 1
	else:
		k = 0
print(jahr)


def solve():
	year_d = int(input())
	while True:
		year_d += 1
		sort = set(str(year_d))
		if len(sort) >= 4:
			break
	print(year_d)
solve()


def hasOnlyDistincts(no):
	freq = [0] * 10
	while no:
		freq[no % 10] += 1
		no //= 10
	for itm in freq:
		if itm > 1:
			return False
	return True
y = int(input())
y += 1
while hasOnlyDistincts(y) != True:
	y += 1
print(y)


n = int(input())
for i in range(n + 1, 10000):
	k = str(i)
	if k[0] != k[1] and k[1] != k[2] and (k[2] != k[3]) and (k[0] != k[2]) and (k[0] != k[3]) and (k[1] != k[3]):
		print(i)
		break


from math import floor
m = int(input())
while True:
	m += 1
	n = m
	a = n % 10
	n = floor(n / 10)
	b = n % 10
	n = floor(n / 10)
	c = n % 10
	n = floor(n / 10)
	if n != a and n != b and (n != c) and (a != b) and (a != c) and (b != c):
		break
print(m)


n = int(input())
for year in range(n + 1, 9013):
	check_year = set()
	string = str(year)
	for j in string:
		check_year.add(int(j))
	if len(check_year) == 4:
		break
print(year)


y = int(input())
stry = str(y)
i = 1
while i > 0:
	if len(set(list(str(y + i)))) == 4:
		print(str(y + i))
		break
	else:
		i += 1


from collections import defaultdict
n = int(input())
while True:
	n += 1
	distint = True
	fre = defaultdict(int)
	for i in str(n):
		fre[i] += 1
	for key in fre:
		if fre[key] > 1:
			distint = False
	if distint:
		print(n)
		break


year = int(input())
for i in range(year + 1, 9013):
	res = set()
	s = str(i)
	for j in s:
		res.add(int(j))
	if len(res) == 4:
		print(i)
		break


n = int(input())
while 1:
	n = n + 1
	t = n
	s = []
	while t != 0:
		s.append(t % 10)
		t = t // 10
	if len(set(s)) == 4:
		for i in range(4):
			print(s.pop(), end='')
		break


def raz_func(year):
	year = list(year)
	if year.count(year[0]) == 1 and year.count(year[1]) == 1 and (year.count(year[2]) == 1) and (year.count(year[3]) == 1):
		return False
	return True

def codeforces():
	n = int(input())
	year = n + 1
	while raz_func(str(year)):
		year += 1
	return year
print(codeforces())


a = int(input())
for x in range(a + 1, a + 1001):
	x = str(x)
	l = [x[0], x[1], x[2], x[3]]
	l = set(l)
	if len(l) == 4:
		break
print(x)


n = input()
n1 = int(n)
f = 1
while f != 0:
	n1 += 1
	k1 = str(n1)
	k = list(k1)
	if len(set(k)) == len(k):
		f = 0
print(n1)


x = int(input())
counter = 0
for i in range(x + 1, 1000000):
	x_str = str(i)
	if x_str[0] != x_str[1] and x_str[0] != x_str[2] and (x_str[0] != x_str[3]) and (x_str[1] != x_str[2]) and (x_str[1] != x_str[3]) and (x_str[2] != x_str[3]):
		print(i)
		break


y = int(input())
n = y + 1
t = n
t = list(str(t))
t.sort()
while t[0] == t[1] or t[1] == t[2] or t[2] == t[3]:
	n += 1
	t = n
	t = list(str(t))
	t.sort()
print(n)


n = int(input())
while 1:
	n = n + 1
	n = list(str(n))
	l = n.copy()
	l = list(set(l))
	if len(l) == len(n):
		print(''.join(n))
		break
	n = int(''.join(n))


a = int(input())
while True:
	a += 1
	e = str(a)
	b = list(map(int, e))
	c = set(b)
	if len(b) == len(c):
		print(a)
		exit()


y = int(input())
i = y + 1
for i in range(y + 1, 9876):
	l = list(str(i))
	if int(l[0]) != int(l[1]) and int(l[0]) != int(l[2]) and (int(l[0]) != int(l[3])) and (int(l[1]) != int(l[2])) and (int(l[1]) != int(l[3])) and (int(l[2]) != int(l[3])):
		print(i)
		break


inputs = int(input())
truth = False
while truth == False:
	inputs += 1
	e = str(inputs)
	if (e[0:1] != e[1:2] and e[0:1] != e[2:3] and (e[0:1] != e[3:4])) and (e[1:2] != e[2:3] and e[1:2] != e[3:4]) and (e[2:3] != e[3:4]):
		truth = True
print(inputs)


a = int(input())
a += 1
while True:
	t = str(a)
	if t[0] != t[1] and t[0] != t[2] and (t[0] != t[3]) and (t[1] != t[2]) and (t[1] != t[3]) and (t[2] != t[3]):
		print(a)
		break
	else:
		a += 1


n = input()
arr = list(map(str, list(str(int(n) + 1))))
n = int(n)
while len(arr) != len(set(arr)):
	n += 1
	arr = list(map(str, list(str(int(n) + 1))))
else:
	print(''.join(arr))


def ss():
	global n
	log1 = False
	for i in range(3):
		for j in range(i + 1, 4):
			if n[i] == n[j]:
				log1 = True
	if log1 == True:
		return False
	else:
		return True
log = False
n = input()
while log != True:
	n = str(int(n) + 1)
	log = ss()
print(n)


y = str(int(input()) + 1)
while True:
	if sum((1 for x in y if y.count(x) == 1)) == len(y):
		print(y)
		break
	y = str(int(y) + 1)


def isbeautiful(anum):
	astr = str(anum)
	aset = set([astr[0], astr[1], astr[2], astr[3]])
	if len(aset) == 4:
		aaaa = True
	else:
		aaaa = False
	return aaaa
thisyear = int(input())
newyear = thisyear + 1
while not isbeautiful(newyear):
	newyear = newyear + 1
print(newyear)


n = input()
(s, r) = ('', 0)
for i in range(1, 10):
	for j in range(10):
		for k in range(10):
			for f in range(10):
				if i != j and i != k and (i != f) and (j != k) and (j != f) and (k != f):
					s = str(i) + str(j) + str(k) + str(f)
					if int(s) > int(n):
						r = r + 1
						break
			if r == 1:
				break
		if r == 1:
			break
	if r == 1:
		break
print(s)


print([i for i in range(int(input()) + 1, 10235) if len(set(str(i))) == len(str(i))][0])


def is_distinct(s):
	s_list = list(s)
	s_set = set(s_list)
	if len(s_list) == len(s_set):
		return True
	else:
		return False
year = int(input())
for i in range(1, 9001):
	year += 1
	if is_distinct(str(year)):
		print(year)
		break


n = int(input())
x = []
for i in range(n + 1, 9013):
	b = list(set(str(i)))
	if len(b) == 4:
		x.append(i)
print(min(x))


g = 10000
t = int(input())
for i in range(t + 1, int(g)):
	d = {}
	n = i
	while i > 0:
		r = i % 10
		if i in d:
			d[r] += 1
		else:
			d[r] = 1
		i = i // 10
	count = 0
	for i in d:
		if d[i] > 1:
			continue
		else:
			count += 1
	if count == 4:
		print(n)
		break


n = int(input())
while True:
	n = n + 1
	l = {int(x) for x in str(n)}
	if len(l) == 4:
		print(n)
		break


n = input()
k = int(n)
flag = 1
while flag:
	k += 1
	a = str(k)
	l = []
	for i in a:
		l.append(i)
	l = list(set(l))
	if len(l) == 4:
		flag = 0
	else:
		continue
print(k)


from itertools import count
from collections import Counter
Y = int(input())
for n in count(Y + 1):
	c = Counter(str(n))
	if len(c) == len(str(n)):
		print(n)
		break


y = int(input())
while True:
	y += 1
	num = y
	v = [0] * 10
	while num:
		if v[num % 10] == 1:
			break
		v[num % 10] = 1
		num = num // 10
	if num == 0:
		break
print(y)


m = int(input())
test = False
while test == False:
	m = m + 1
	n = str(m)
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		test = True
print(n)


l = int(input())
for i in range(l + 1, 9013):
	n = [int(x) for x in str(i)]
	n.sort()
	f = 0
	for j in range(0, len(n) - 1):
		if n[j + 1] - n[j] == 0:
			f = 1
			break
	if f == 0:
		print(i)
		break


year = int(input())
is_beautiful = False
while not is_beautiful:
	year += 1
	if len(set(str(year))) == len(str(year)):
		is_beautiful = True
print(year)


t = int(input())
b = False
while not b:
	t += 1
	c = 0
	for r in str(t):
		c += str(t).count(r)
	if c == len(str(t)):
		b = True
print(t)


y = int(input())
a = b = c = d = 0
while y != 0:
	y += 1
	a = y // 1000
	b = y % 1000 // 100
	c = y % 100 // 10
	d = y % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(y)


y = input()
res = int(y)
while True:
	res += 1
	if str(res)[0] == str(res)[1] or str(res)[1] == str(res)[2] or str(res)[2] == str(res)[3] or (str(res)[1] == str(res)[3]) or (str(res)[3] == str(res)[0]) or (str(res)[2] == str(res)[0]):
		continue
	else:
		print(res)
		break


n = input()
x = int(n)
s = list(n)
if len(set(s)) <= 4:
	s = list(set(str(x + 1)))
	while len(set(s)) < 4:
		x += 1
		s = list(str(x))
if x == int(n):
	print(x + 1)
else:
	print(x)


year = int(input())

def solve(number):
	x = set(str(number))
	return len(x) == 4
index = year + 1
while True:
	if solve(index):
		print(index)
		break
	index += 1


z = int(input())
s = False
while s == False:
	z += 1
	if len(set(str(z))) == len(str(z)):
		s = True
print(z)


def same(n):
	l = []
	while n > 0:
		l.append(n % 10)
		n = n // 10
	for i in range(4):
		for j in range(i + 1, 4):
			if l[i] == l[j]:
				return True
	return False
num = int(input()) + 1
while same(num):
	num += 1
print(num)


Y = int(input()) + 1
while len(set(str(Y))) != 4:
	Y += 1
print(Y)


a = int(input())
a += 1
b = a % 10
c = (a % 100 - b) // 10
x = (a % 1000 - c - b) // 100
y = (a % 10000 - c - b - x) // 1000
for i in range(9000):
	if (b == c or b == x or b == y) or (c == b or c == x or c == y) or (x == c or x == b or x == y) or (y == c or y == x or y == b):
		a += 1
		b = a % 10
		c = (a % 100 - b) // 10
		x = (a % 1000 - c - b) // 100
		y = (a % 10000 - c - b - x) // 1000
else:
	print(a)


def main():
	ano = str(int(input()) + 1)
	while rep(ano):
		ano = str(int(ano) + 1)
	print(ano)

def rep(ano):
	for i in range(4):
		for j in range(i + 1, 4):
			if ano[i] == ano[j]:
				return True
	return False
main()


def checking(year):
	first_d = int(year / 1000)
	second_d = int(year / 100 % 10)
	third_d = int(year / 10 % 10)
	fourth_d = int(year % 10)
	if first_d != second_d and first_d != third_d and (first_d != fourth_d) and (second_d != third_d) and (second_d != fourth_d) and (third_d != fourth_d):
		return True
	else:
		return False
year = int(input())
year = year + 1
while True:
	isDistinct = checking(year)
	if isDistinct == True:
		print(year)
		break
	else:
		year = year + 1


inputedYear = input()
year = inputedYear
while True:
	year = int(year) + 1
	year = str(year)
	if not (year[0] == year[1] or year[0] == year[2] or year[0] == year[3] or (year[1] == year[2]) or (year[1] == year[3]) or (year[2] == year[3])):
		print(int(inputedYear) + 1) if inputedYear == year else print(''.join(year))
		break


input_year = int(input())
storage = []
for x in range(input_year + 1, 1000000):
	string_x = str(x)
	storage.append(string_x[0])
	if string_x[1] not in storage:
		storage.append(string_x[1])
		if string_x[2] not in storage:
			storage.append(string_x[2])
			if string_x[3] not in storage:
				print(x)
				break
	storage.clear()


n = input()
new_n = n

def func(god):
	god = list(god)
	d = dict()
	for i in god:
		key = i
		if key not in d:
			d[key] = 0
		d[key] += 1
	if len(d.keys()) == 4:
		print(''.join(god))
		raise SystemExit
for i in range(8000):
	new_n = int(new_n)
	new_n += 1
	func(str(new_n))


n = list(input())
n[0] = int(n[0])
n[1] = int(n[1])
n[2] = int(n[2])
n[3] = int(n[3]) + 1
while 1:
	if n[0] == n[1] or n[1] == n[2] or n[2] == n[3] or (n[0] == n[2]) or (n[0] == n[3]) or (n[1] == n[3]) or (n[3] >= 10):
		n[3] = n[3] + 1
		if n[3] >= 10:
			n[2] = n[2] + 1
			n[3] = 0
			if n[2] == 10:
				n[1] = n[1] + 1
				n[2] = 0
				if n[1] == 10:
					n[0] = n[0] + 1
					n[1] = 0
	else:
		no = n[0] * 1000 + n[1] * 100 + n[2] * 10 + n[3]
		break
print(no)


num = int(input()) + 1
ans = False
while not ans:
	digits = []
	for n in str(num):
		digits.append(int(n))
	ans = len(set(digits)) == len(digits)
	if not ans:
		num += 1
print(num)


n = int(input())
while True:
	n += 1
	a = list(str(n))
	if len(a) == len(set(a)):
		print(''.join(a), end='')
		break


def solve(year):
	while True:
		year = year + 1
		stryear = str(year)
		lst = list(stryear)
		if len(lst) == len(set(lst)):
			return stryear
			break
		else:
			lst.clear()
year = int(input())
newyear = solve(year)
print(newyear)


l = int(input())
l = l + 1
while 0 < 1:
	m = str(l)
	if any((m.count(i) > 1 for i in m)):
		l = l + 1
	else:
		print(l)
		break


def isDistinct(year):
	for i in range(0, 4):
		for j in range(0, 4):
			if i != j:
				if year[i] == year[j]:
					return False
	return True
year = int(input())
for i in range(year + 1, 100000):
	if isDistinct(str(i)):
		print(i)
		break


def checkDistinctNumbers(number):
	numbers_dict = dict()
	while number > 0:
		rest = number % 10
		if rest in numbers_dict:
			return False
		else:
			numbers_dict[rest] = 1
		number = number // 10
	return True

def main():
	y = int(input())
	for i in range(y + 1, 10000):
		if checkDistinctNumbers(i):
			print(i)
			return
	return
main()


current_year = input()
year = []
for i in current_year:
	i = int(i)
	year.append(i)
current_year = int(current_year)
for distinct in range(current_year + 1, 12345):
	distinct = str(distinct)
	years = []
	for f in distinct:
		f = str(f)
		years.append(f)
	repeat = set(years)
	if len(repeat) == len(years):
		output = ''
		for a in years:
			output += a
		break
	elif len(repeat) != len(years):
		continue
print(int(output))


from collections import Counter
n = int(input())

def solve(n):
	x = len(Counter(str(n)))
	if x == 4:
		return True
	else:
		return False
while True:
	n += 1
	if solve(n) == True:
		print(n)
		break


import sys
year = int(input())
if year >= 1987 and year < 2013:
	print(2013)
else:
	for i in range(year + 1, 9013):
		strYear = str(i)
		boolean = True
		dic = {}
		for j in strYear:
			if j in dic:
				boolean = False
				break
			else:
				dic[j] = 1
		if boolean:
			print(i)
			sys.exit(0)


def distinct(i1):
	if len(set(str(i1))) == len(str(i1)):
		return 1
	else:
		return 0
s = int(input())
for i in range(s + 1, 900000):
	if distinct(i) == 1:
		break
print(i)


from collections import Counter as coun
s = int(input())
s += 1
flag = 0
while s <= 10000:
	a = coun(str(s))
	if min(a.values()) == 1 and max(a.values()) == 1:
		print(s)
		break
	else:
		s += 1


a = int(input())
s = a + 1

def sorteds(s):
	a = list(s)
	a.sort()
	for i in range(1, len(a)):
		j = i - 1
		if a[i] == a[j]:
			return True
	return False
while sorteds(str(s)):
	s += 1
print(s)


y = input()
y = int(y)
while True:
	y = y + 1
	string = str(y)
	prep1 = list(string)
	prep2 = set(string)
	if len(prep1) == len(prep2):
		print(y)
		break


s = int(input()) + 1

def getnum():
	global s
	s = str(s)
	count = 0
	l = []
	for i in s:
		if i not in l:
			l.append(i)
			count = count + 1
	if count == 4:
		print(s)
	else:
		s = int(s) + 1
		getnum()
getnum()


year = input()

def checkDuplicates(arr):
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			if arr[i] == arr[j]:
				return 0
	return 1

def check(year):
	arr = [item for item in str(year)]
	if checkDuplicates(arr) == 1:
		print(''.join(arr))
		return 1
	else:
		return 0
for i in range(int(year) + 1, 9013):
	if check(i) == 1:
		break


year = int(input())
year += 1
while 1:
	lent1 = len(str(year))
	lent2 = len(set(str(year)))
	if lent1 == lent2:
		break
	year += 1
print(year)


y = int(input())
for i in range(y + 1, 9013):
	unique = ''
	for j in range(len(str(i))):
		if str(i)[j] not in unique:
			unique += str(i)[j]
	if unique == str(i):
		print(i)
		break


Year = input()
Year = int(Year)
Year = Year + 1
Year = str(Year)
FoundDistinctYear = False
while FoundDistinctYear == False:
	distinct = []
	for i in Year:
		if i not in distinct:
			distinct.append(i)
	if len(distinct) == 4:
		FoundDistinctYear = True
	else:
		Year = int(Year)
		Year = Year + 1
		Year = str(Year)
print(Year)


y = int(input())
for i in range(y + 1, 9013):
	s = str(i)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		break


s = int(input(''))
count = 0
for i in range(5000):
	s1 = str(s + 1)
	list1 = []
	for i in s1:
		list1.append(i)
	set3 = list(set(list1))
	for j in set3:
		count += 1
	if count == 4:
		print(s1)
		break
	else:
		s = int(s1)
		count = count - count


def func1(y):
	y = str(y)
	i = 0
	while i < 3:
		j = i + 1
		while j < 4:
			if y[i] == y[j]:
				return True
			j += 1
		i += 1
	return False
y = int(input())
i = 0
while True:
	y += 1
	if func1(y) == False:
		break
	y = int(y)
print(y)


def distinct_year(year):
	year = list(str(year))
	unique_year = list(set(year))
	if len(year) == len(unique_year):
		return True
	else:
		return False
year = int(input())
while True:
	year += 1
	if distinct_year(year):
		print(year)
		break


t = int(input())
r = t + 1
while t > 0:
	if len(set(str(r))) == 4:
		break
	else:
		r = int(r) + 1
print(r)


n = int(input())
while True:
	n += 1
	m = str(n)
	if m.count(m[0]) == 1 and m.count(m[1]) == 1 and (m.count(m[2]) == 1) and (m.count(m[3]) == 1):
		print(n)
		break


y = int(input())
n = y
l = []
while len(l) < 4:
	n = n + 1
	n = str(n)
	d = {}
	for i in n:
		d[i] = 0
	n = int(n)
	l = list(dict(d).keys())
ans = ''
ans = ans.join(l)
print(ans)


n = int(input())
t = 0
while t != 4:
	n += 1
	s = ''
	for i in str(n):
		if i not in s:
			s += i
	t = len(s)
print(n)


n = int(input())
n = n + 1
lol = True
while lol:
	i = n % 10
	j = n // 10 % 10
	k = n // 100 % 10
	l = n // 1000 % 10
	if i != j and i != k and (i != l) and (j != k) and (j != l) and (k != l):
		lol = False
		print(n)
	else:
		n += 1


n = int(input()) + 1

def yes(a):
	a = str(a)
	if len(a) == len(set(a)):
		return True
	return False
while True:
	if yes(n):
		print(n)
		break
	n += 1


m = int(input())
ans = 0
mx = 0
for z in range(m + 1, 15000):
	n = str(z)
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				ans = 1
				break
		if ans == 1:
			break
	if ans == 0:
		mx = n
		break
	else:
		ans = 0
print(mx)


n_year = str(int(input()) + 1)
while len(set(n_year)) != 4:
	n_year = str(int(n_year) + 1)
print(n_year)


def compare_digits(year):
	temp = year + 1
	while True:
		curr = [int(d) for d in str(temp)]
		if curr[0] != curr[1] and curr[0] != curr[2] and (curr[0] != curr[3]) and (curr[1] != curr[2]) and (curr[1] != curr[3]) and (curr[2] != curr[3]):
			return temp
		else:
			temp += 1
year = int(input())
print(compare_digits(year))


number = int(input()) + 1
lst = list(str(number))
while len(set(lst)) != len(lst):
	number += 1
	lst = list(str(number))
print(number)


n = int(input())
x = n + 1
z = list()
while True:
	n = x
	l = []
	while n > 0:
		t = n % 10
		l.append(t)
		n = n // 10
	p = set(l)
	if len(p) == len(l):
		l.reverse()
		z = l
		break
	x += 1
for i in z:
	print(i, end='')


from collections import Counter
n = int(input())
for i in range(n + 1, 10000):
	if len(Counter([int(x) for x in str(i)]).keys()) == 4:
		print(i)
		break


n = int(input())
b = True
while b:
	n = n + 1
	if len(set(str(n))) == len(str(n)):
		b = False
print(n)


n = int(input())
for i in range(101):
	n = n + 1
	kol = set(str(n))
	if len(kol) == 4:
		print(n)
		break
	else:
		continue


n = int(input())

def intToList(a):
	num1 = []
	while a >= 1:
		b = a % 10
		a = int(a / 10)
		num1.append(b)
	return num1
for i in range(1, 150):
	m = n + i
	num2 = intToList(m)
	a = len(num2)
	b = len(set(num2))
	if a == b:
		z = m
		break
	else:
		continue
print(z)


for i in range(int(input()) + 1, 9877):
	if len(set(str(i))) < 4:
		i += 1
	else:
		print(i)
		break


def findYear(c):
	t = c
	while True:
		t += 1
		a1 = t // 1000
		a2 = (t - a1 * 1000) // 100
		a3 = (t - a1 * 1000 - a2 * 100) // 10
		a4 = t - a1 * 1000 - a2 * 100 - a3 * 10
		if a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a2 != a4) and (a3 != a4):
			return t
a = int(input())
c = findYear(a)
print(c)


def check(old):
	judge = 1
	s = str(old)
	for i in range(3):
		j = i + 1
		while j < 4:
			if s[i] == s[j]:
				judge = 0
				break
			j += 1
		if not judge:
			break
	return judge
old = int(input())
j = 0
while not j:
	old = old + 1
	j = check(old)
print(old)


def unique(y):
	return len(str(y)) == len(set(str(y)))
y = int(input().strip()) + 1
c = 1
d = 1
while y // d > 0 and (not unique(y // d)):
	if y % (d * 10) == 0:
		d *= 10
		continue
	y += d
d //= 10
while d > 0 and (not unique(y)):
	if unique(y // d):
		d //= 10
		continue
	y += d
print(y)


x = input()
c = 0
p = x
f = 0
s = 0
t = 0
l = 0
k = 0
while c < 9000:
	p = int(p) + 1
	k = str(p)
	c = 0
	while c < len(x):
		if c == 0:
			f = k[c]
		elif c == 1:
			s = k[c]
		elif c == 2:
			t = k[c]
		elif c == 3:
			l = k[c]
		c += 1
	if int(f) != int(s) and int(f) != int(t) and (int(f) != int(l)) and (int(s) != int(t)) and (int(s) != int(l)) and (int(t) != int(l)):
		print(f + s + t + l)
		exit()
	c += 1


ip = str(int(input()) + 1)
count = 0
while count != 1:
	in1 = list(map(int, ip))
	unq = []
	for x in in1:
		if x not in unq:
			unq.append(x)
	if len(ip) == len(unq):
		print(''.join(map(str, unq)))
		count = 1
	else:
		ip = int(ip) + 1
		ip = str(ip)


n = int(input())
for i in range(n + 1, 9999):
	tmp = i
	a = tmp % 10
	b = tmp // 10 % 10
	c = tmp // 100 % 10
	d = tmp // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		break


def main():
	year = int(input('')) + 1
	while 1:
		if len(str(year)) == len(set(str(year))):
			break
		else:
			year = int(year) + 1
	print(year)
main()


year = int(input())
ans = 0
for i in range(year + 1, 9013):
	con = 0
	for j in range(3):
		k = str(i)
		if k[j] in k[:j] + k[j + 1:]:
			con = 1
	if con == 0:
		ans = i
		break
print(ans)


y = int(input())

def dist(y):
	distinct = True
	y = str(y)
	for i in y:
		if y.count(i) > 1:
			distinct = False
			return distinct
	return distinct
y1 = y + 1
while not dist(y1):
	y1 += 1
print(y1)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
i = n + 1
while 1:
	a = list(str(i))
	a = set(a)
	if len(a) == 4:
		break
	i += 1
print(i)


n = int(input())
n = n + 1
for i in range(1, 8000):
	x = n
	l = []
	for i in range(4):
		a = x % 10
		x = x // 10
		l.append(a)
		b = set(l)
	if len(b) == 4:
		print(n)
		break
	else:
		n = n + 1


import math
from sys import stdin

def si():
	return str(input())

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
m = int(input()) + 1
while len(set(str(m))) < 4:
	m += 1
print(m)


a = int(input())
a = a + 1
while 1:
	c = list(map(int, str(a)))
	d = set(c)
	if len(c) == len(d):
		print(a)
		break
	else:
		a = a + 1


from collections import deque
import math
n = int(input())
while True:
	n += 1
	if n // 1000 != n % 1000 // 100 and n // 1000 != n % 100 // 10 and (n // 1000 != n % 10):
		if n % 1000 // 100 != n % 100 // 10 and n % 1000 // 100 != n % 10:
			if n % 100 // 10 != n % 10:
				print(n)
				break


def Main():
	m = int(input())
	m += 1
	while True:
		cnt = [0] * 10
		cnt[m % 10] += 1
		cnt[m // 10 % 10] += 1
		cnt[m // 100 % 10] += 1
		cnt[m // 1000] += 1
		for i in range(10):
			if cnt[i] > 1:
				cnt[0] = -1
				break
		if cnt[0] != -1:
			print(m)
			break
		m += 1
Main()


n = int(input())

def main(x):
	x = str(x)
	a = set(x)
	if len(a) == 4:
		return True
	else:
		return False
while True:
	n = n + 1
	if main(n) == True:
		print(n)
		break


import math
year = int(input()) + 1

def check(year):
	answer = True
	digits = [0 for _ in range(10)]
	while year != 0:
		digit = year % 10
		if digits[digit] != 0:
			answer = False
			break
		digits[digit] = 1
		year = math.floor(year / 10)
	return answer
answer = 0
while answer == 0:
	if check(year):
		answer = year
	year += 1
print(answer)


year = int(input())

def is_happy(v):
	a = str(v)
	b = set(a)
	return True if len(a) == len(b) else False
year += 1
while not is_happy(year):
	year += 1
print(year)


y = int(input())
while True:
	y += 1
	b_y = {*str(y)}
	if len(b_y) == 4:
		break
print(y)


year = int(input())
num = 0
while True:
	year += 1
	yearset = set(str(year))
	if len(yearset) == 4:
		print(year)
		exit()


def only(s):
	return len(set(s)) == len(s)
a = int(input())
for i in range(1, 100000):
	if only(str(i + a)):
		print(i + a)
		break


nextYear = int(input()) + 1
while len(set(list(str(nextYear)))) < 4:
	nextYear += 1
print(nextYear)


n = int(input())
n += 1
s = str(n)
while s[0] == s[1] or s[1] == s[2] or s[2] == s[3] or (s[0] == s[2]) or (s[0] == s[3]) or (s[1] == s[3]):
	n += 1
	s = str(n)
print(n)


y = int(input())
l = 0
while l != 4:
	y += 1
	a = set(str(y))
	l = len(a)
print(y)


s = int(input())
x = str(s + 1)
y = s + 1
while len(list(set(x))) < len(str(s)):
	y = y + 1
	x = str(y)
print(y)


def solve():
	n = int(input())
	i = 0
	while True:
		n += 1
		s = set(str(n))
		if len(s) == 4:
			print(n)
			break
		i += 1
solve()


year = int(input())
year += 1
houssem = str(year)
while houssem[0] == houssem[1] or houssem[0] == houssem[2] or houssem[0] == houssem[3] or (houssem[1] == houssem[2]) or (houssem[1] == houssem[3]) or (houssem[2] == houssem[3]):
	year += 1
	houssem = str(year)
print(year)


def check_digits(n):
	first = n % 10
	second = n // 10 % 10
	third = n // 100 % 10
	fourth = n // 1000
	if first != second and second != third and (third != fourth) and (first != fourth) and (first != third) and (second != fourth):
		return True
	else:
		return False

def main():
	year = input()
	while True:
		year = int(year) + 1
		if check_digits(year):
			break
	print(year)
main()


n = int(input())
flag = 0
temp = n
while not flag:
	temp += 1
	y = temp
	l = []
	while y > 0:
		if y % 10 not in l:
			l.append(y % 10)
		y //= 10
	if len(l) == 4:
		flag = 1
print(temp)


n = int(input())
for _ in range(n + 1, 9013):
	l = list(str(_))
	if len(set(l)) == len(l):
		print(_)
		break


n = int(input())
i = n + 1
while True:
	s = {i % 10, i // 10 % 10, i // 100 % 10, i // 1000}
	if len(s) == 4:
		print(i)
		break
	i += 1


from collections import deque
import math
import os
import random
import re
import sys

def main():
	y = int(input())
	while True:
		y += 1
		a = y // 1000
		b = y // 100 % 10
		c = y // 10 % 10
		d = y % 10
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			break
	print(y)
	return 0
main()


from sys import stdin
y = int(stdin.readline().rstrip()) + 1
while len(set(str(y))) != 4:
	y += 1
print(y)


a_str = input()
a_int = int(a_str)
count = 0
flag = 1
i = a_int + 1
list = []
while flag:
	list.append(str(i)[0])
	i_str = str(i)
	for j in range(1, len(i_str)):
		if i_str[j] not in list:
			list.append(i_str[j])
			count += 1
			if count == len(i_str) - 1:
				flag = 0
				break
	i += 1
	list = []
	count = 0
print(i - 1)


def beautifulYear(year):
	while year <= 9050:
		temp = ''
		for i in str(year + 1):
			if i not in temp:
				temp += i
		if len(temp) == 4:
			return int(temp)
		year = int(year) + 1
year = int(input())
print(beautifulYear(year))


n = int(input())
while True:
	n += 1
	a = n // 100
	b = n % 100
	c = a // 10
	d = a % 10
	e = b // 10
	f = b % 10
	if c != d and c != e and (c != f) and (d != e) and (d != f) and (e != f):
		print(n)
		break


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
n = ii()
y = n + 1
while len(set(str(y))) < 4:
	y += 1
print(y)


t = int(input())
d = [0] * 4
for i in range(t + 1, 9015):
	n = i
	s = 0
	while n > 0:
		d[s] = n % 10
		s += 1
		n = n // 10
		s1 = set(d)
	if len(s1) == 4:
		print(i)
		break


current_year = input()

def is_distinct_year(year):
	for i in range(10):
		if year.count(str(i)) > 1:
			return False
	return True
i = 1
while True:
	new_year = str(int(current_year) + i)
	if is_distinct_year(new_year):
		print(new_year)
		break
	i += 1


def check(n):
	l = []
	for i in str(n):
		l.append(int(i))
	l = set(l)
	if len(l) == len(str(n)):
		return True
	else:
		return False
n = int(input())
for i in range(n + 1, 10000):
	if check(i):
		print(i)
		break


from collections import Counter
num = int(input())
check = True
l = num + 1
while check:
	if len(str(l)) != len(set(str(l))):
		l += 1
	else:
		print(l)
		check = False


year = int(input())
while True:
	year += 1
	mill = year // 1000
	cent = year // 100 % 10
	dec = year // 10 % 10
	num = year % 10
	if mill != cent and mill != dec and (mill != num) and (cent != dec) and (cent != num) and (dec != num):
		break
print(year)


def AoHermoso(N):
	A = N
	U = A % 10
	A = A // 10
	D = A % 10
	A = A // 10
	C = A % 10
	UM = A // 10
	if U != D and U != C and (U != UM) and (D != C) and (D != UM) and (C != UM):
		return 1
	else:
		return 0
L = int(input())
O = 0
if 1000 <= L <= 9000:
	while O != 1:
		L += 1
		O = AoHermoso(L)
	print(L)


n = int(input())
n += 1
a = list(map(int, ' '.join(str(n)).split()))
while len(a) != len(set(a)):
	n += 1
	a = list(map(int, ' '.join(str(n)).split()))
print(n)


y = int(input())
a = [0] * 10
f = -1
while f == -1:
	y += 1
	z = y
	while z > 0:
		a[z % 10] += 1
		z //= 10
	if 2 in a or 3 in a or 4 in a:
		a = [0] * 10
	else:
		f = 1
print(y)


def all_distinct(n):
	return len(n) == len(set(n))
n = int(input())
m = n + 1
found = False
while not found:
	if all_distinct(str(m)):
		found = True
	else:
		m += 1
print(m)


def unique(x):
	x = str(x)
	x2 = ''
	for i in x:
		if i not in x2:
			x2 = x2 + i
	if x == x2:
		return True
	else:
		return False
y = int(input())
y1 = y + 1
while unique(y1) == False:
	y1 += 1
print(y1)


s = int(input())
while True:
	s += 1
	s1 = str(s)
	a = set()
	for i in s1:
		a.add(i)
	if len(a) == len(s1):
		print(s1)
		break


l = int(input())
l = l + 1
while True:
	m = set(str(l))
	if len(m) == 4:
		print(l)
		break
	l += 1


N = input()
P = int(N)
while 1:
	P += 1
	R = list(str(P))
	if R[0] != R[1] and R[0] != R[1] and (R[0] != R[2]) and (R[0] != R[3]) and (R[1] != R[2]) and (R[1] != R[3]) and (R[2] != R[3]):
		break
print(P)


u = int(input()) + 1
while 1:
	if len(set(str(u))) == 4:
		print(u)
		exit()
	else:
		u += 1


def check(n):
	ret = True
	ns = list(str(n))
	while len(ns) > 1:
		s = ns.pop()
		if s in ns:
			ret = False
			break
	return ret
inp1 = int(input().strip())
num1 = inp1 + 1
while not check(num1):
	num1 += 1
print(num1)


import math
x = int(input())
e = 1
while e < 2:
	x += 1
	a = int(x / 1000)
	b = int(x % 1000 / 100)
	c = int(x % 100 / 10)
	d = int(x % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(x)
		e += 1


year = int(input())
n = 0
while n < 1:
	year += 1
	if len(set(str(year))) == 4:
		print(year)
		n = 10


def compare(s, a):
	s = str(s)
	c = 1
	for b in range(0, 4):
		if a != b and s[b] == s[a]:
			c = 0
			break
	if c == 1:
		return True
	else:
		return False
s = int(input())
count = s + 1
c = 0
b = 0
while c == 0:
	for a in range(0, 4):
		if compare(count, a) == False:
			b = 1
	if b == 1:
		count += 1
		b = 0
	else:
		c = 1
print(count)


n = int(input())
while True:
	n += 1
	l = [int(x) for x in str(n)]
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]):
		if l[1] != l[2] and l[1] != l[3]:
			if l[2] != l[3]:
				print(n)
				exit()
			else:
				continue
		else:
			continue
	else:
		continue


y = int(input())
while y <= 9999:
	y += 1
	s = set()
	for ch in f'{y}':
		s.add(ch)
	if len(s) == 4:
		print(y)
		break


year = int(input()) + 1
while year < 10000:
	count = 0
	a = int(year / 1000)
	b = int(year / 100) % 10
	c = int(year % 100 / 10)
	d = year % 10
	if d == c:
		year += 1
		count += 1
	if d == b:
		year += 1
		count += 1
	if d == a:
		year += 1
		count += 1
	if c == b:
		year += 10
		count += 1
		year = int(year / 10) * 10
	if c == a:
		year += 10
		count += 1
		year = int(year / 10) * 10
	if b == a:
		year += 100
		count += 1
		year = int(year / 100) * 100
	if count == 0:
		break
print(year)


y = input()
year = str(int(y) + 1)

def isValid(num):
	if len(num) == len(''.join(set(num))):
		return True
	else:
		return False
while isValid(year) == False:
	year = str(int(year) + 1)
print(year)


Y = str(int(input()) + 1)
while True:
	if len(set(Y)) == len(list(Y)):
		print(Y)
		break
	else:
		Y = str(int(Y) + 1)


s = int(input()) + 1
m = str(s)
while any((m[i] == m[i + j] for i in range(len(m)) for j in range(1, 4 - i))):
	s += 1
	m = str(s)
else:
	print(m)


n = int(input())
for i in range(9013 - n):
	n = n + 1
	l = list(str(n))
	a = set(l)
	if len(a) == 4:
		print(n)
		break


def checkDigit(n):
	arr = []
	while n > 0:
		tmp = n % 10
		if tmp in arr:
			return False
		arr.append(tmp)
		n //= 10
	return True

def main(n):
	n += 1
	while not checkDigit(n):
		n += 1
	print(n)
n = int(input())
main(n)


int_year = int(input()) + 1
str_year = str(int_year)
li_origin = list(str_year)
li_origin.sort()
li_del = list(set(li_origin))
li_del.sort()
while li_del != li_origin:
	int_year = int_year + 1
	str_year = str(int_year)
	li_origin = list(str_year)
	li_origin.sort()
	li_del = list(set(li_origin))
	li_del.sort()
print(str_year)


year = int(input())
i = year + 1
while i <= 9012:
	l = []
	l.append(i // 1000)
	l.append(i // 100 % 10)
	l.append(i // 10 % 10)
	l.append(i % 10)
	s = set(l)
	if len(s) == 4:
		j = 0
		while j < 4:
			print(l[j], end='')
			j = j + 1
		exit()
	i = i + 1


import sys
n = int(sys.stdin.readline().rstrip())
nn = n + 1
while nn < 100000:
	temp = set(str(nn))
	if len(temp) == len(str(nn)):
		print(nn)
		break
	else:
		nn += 1


for i in range(int(input()) + 1, 9014):
	if len(str(i)) == len(set(str(i))):
		print(i)
		break


def is_beautiful(n):
	digits = {}
	while n > 0:
		d = n % 10
		if d not in digits:
			digits[d] = 0
		digits[d] += 1
		if digits[d] > 1:
			return False
		n = n // 10
	return True
n = int(input()) + 1
while True:
	if is_beautiful(n):
		print(n)
		exit(0)
	n += 1


y = int(input())
m = set()
while len(m) != 4:
	y = y + 1
	z = y
	m = set()
	while z != 0:
		m.add(z % 10)
		z = z // 10
print(y)


n = int(input())

def per(n):
	t = False
	for i in range(0, len(n)):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				return per(str(int(n) + 1))
	return n
print(per(str(int(n) + 1)))


n = int(input())
n = n + 1
T = 0
while T < 1:
	a1 = n % 10
	a2 = n % 100 // 10
	a3 = n % 1000 // 100
	a4 = n // 1000
	if a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a2 != a4) and (a3 != a4):
		T = 1
	else:
		n = n + 1
print(n)


year = int(input())
year = year + 1

def distinct(year):
	year = str(year)
	count = 0
	for i in range(4):
		for j in range(i + 1, 4):
			if year[i] == year[j]:
				count = count + 1
	if count == 0:
		print(year)
	else:
		year = int(year)
		year = year + 1
		distinct(year)
distinct(year)


b = int(input())
while True:
	b += 1
	a1 = []
	a = str(b)
	for i in range(4):
		a1.append(a[i])
	if len(set(a1)) == 4:
		break
print(b)


yearIn = int(input())
numNextYear = yearIn + 1
i = 0
while i == 0:
	nextYear = str(numNextYear)
	nextYearSplit = nextYear.split()
	nextYearList = []
	for i in nextYearSplit[0]:
		nextYearList.append(i)
	uniqueList = []
	for i in nextYearList:
		if i not in uniqueList:
			uniqueList.append(i)
	if len(uniqueList) == 4:
		print(numNextYear)
		i = 1
	else:
		i = 0
		numNextYear += 1


x = input()
while True:
	x = str(int(x) + 1)
	if len(set(x)) == 4:
		print(x)
		quit()


year = input()

def ye(a):
	a = str(int(a) + 1)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		print(a)
		exit()
	else:
		ye(a)
ye(year)


ans = int(input()) + 1
s = str(ans)

def beatiful(x):
	a = []
	for char in x:
		if char not in a:
			a.append(char)
	if len(a) == len(x):
		return 1
	else:
		return 0
while beatiful(s) == 0:
	ans += 1
	s = str(ans)
print(ans)


y = int(input())
a = 0
while a < 3:
	y += 1
	Year = list(str(y))
	Year.sort()
	for i in range(3):
		if Year[i] != Year[i + 1]:
			a += 1
		else:
			a = 0
			break
print(y)


def beautiful(year):
	year = str(year)
	for letter_no in range(len(year)):
		if year[letter_no + 1:].find(year[letter_no]) != -1:
			return False
	return True
year = int(input())
while True:
	year += 1
	if beautiful(year):
		print(year)
		break


def isBeautifulYear(n):
	return len(set([i for i in str(n)])) == len(str(n))
n = int(input())
n += 1
while not isBeautifulYear(n):
	n += 1
print(n)


import sys

def solve():
	y = int(input())
	for x in range(y + 1, 10 ** 5):
		xc = x
		a = set()
		for j in range(4):
			a.add(xc % 10)
			xc //= 10
		if len(a) == 4:
			print(x)
			return
solve()


y = int(input())
for i in range(y + 1, 9013):
	setnum = set(str(i))
	if len(str(i)) == len(setnum):
		print(i)
		break


n = int(input())
l = list(str(n))
m = list(str(n + 1))
s = ''
i = 2
while len(l) > len(set(m)):
	m = list(str(n + i))
	i += 1
print(s.join(m))


x = int(input())
for i in range(x + 1, 9013):
	c = []
	a = str(i)
	for j in range(len(a)):
		c.append(a[j])
	if c[0] != c[1] and c[0] != c[2] and (c[0] != c[3]) and (c[1] != c[2]) and (c[1] != c[3]) and (c[2] != c[3]):
		print(i)
		break


n = int(input())

def year(a):
	b = str(a)
	b = list(b.split())
	k = 0
	for i in range(3):
		for j in range(i + 1, 4):
			if b[0][i] == b[0][j]:
				k = k + 1
			else:
				k = k
	if k == 0:
		return True
	else:
		return False
n = n + 1
y = True
while y:
	if year(n):
		print(n)
		y = False
	else:
		n = n + 1


from collections import Counter

def isAllUnique(year):
	results = Counter(year)
	values = results.values()
	onces = [y for y in values if y == 1]
	if len(onces) == 4:
		return True
	else:
		return False
year = int(input())
nextYear = year + 1
while not isAllUnique(str(nextYear)):
	nextYear += 1
print(nextYear)


year = int(input()) + 1
year1 = year
while True:
	year1 = str(year1)
	lis = list(year1)
	c = {}
	for item in lis:
		c[item] = c.get(item, 0) + 1
	n = max(c.values())
	if n > 1:
		year1 = int(year1) + 1
	else:
		print(year1)
		break


def split_num(n):
	out = []
	while n > 0:
		r = n % 10
		out.append(r)
		n //= 10
	return out

def is_all_disctinct(y):
	return len(set(split_num(y))) == 4
year = int(input())
for y in range(year + 1, 9223372036854775807):
	if is_all_disctinct(y):
		print(y)
		break


user = input()
num = int(user) + 1
while len(user) != len(set(str(num))):
	num += 1
print(num)


y = int(input())

def beautiful(y):
	x = str(y)
	l = [x[0], x[1], x[2], x[3]]
	s = set(l)
	if len(s) == 4:
		return True
	else:
		return False
x = y
for i in range(y + 1, 10000):
	x += 1
	if beautiful(x):
		print(x)
		break


year = int(input()) + 1
while 1:
	if len(list(str(year))) == len(set(str(year))):
		print(year)
		break
	year += 1


def Convert(string):
	list1 = []
	list1[:0] = string
	return list1
n = int(input())
n += 1
s = str(n)
l = Convert(s)
flag = len(set(l)) == len(l)
while flag != True:
	n += 1
	s = str(n)
	l = Convert(s)
	flag = len(set(l)) == len(l)
print(n)


a = int(input())
a += 1
flag = 1
while flag:
	b = [i for i in str(a)]
	if len(set(b)) == 4:
		print(a)
		break
	else:
		a += 1


def uniqueDigits(n):
	digits = dict()
	for i in str(n):
		if i in digits:
			return False
		digits[i] = 1
	return True
s = int(input())
ct = 0
while True:
	s += 1
	if uniqueDigits(s):
		break
print(s)


a = input()
b = int(a)
for i in range(b + 1, 100000000):
	kaj = str(i)
	if kaj.count(kaj[0]) == 1 and kaj.count(kaj[1]) == 1 and (kaj.count(kaj[2]) == 1) and (kaj.count(kaj[3]) == 1):
		print(i)
		break


ans = int(input())
while True:
	ans += 1
	c = set(str(ans))
	if len(c) == 4:
		break
str = ''
print(ans)


year = int(input())
digits = set()
temp_year = year + 1
while len(digits) < 4:
	temp_year = year + 1
	digits.clear()
	while temp_year > 0:
		digits.add(str(temp_year % 10))
		temp_year = int(temp_year / 10)
	year = year + 1
print(year)


def year(n):
	a = str(n + 1)
	l = []
	for i in range(0, len(a)):
		l.append(int(a[i]))
	i = 0
	while i >= 0:
		l1 = []
		for i in range(0, len(l)):
			l1.append(l.count(l[i]))
		if l1.count(1) == len(l):
			break
		else:
			n += 1
			a = str(n)
			l = []
			for i in range(0, len(a)):
				l.append(int(a[i]))
			i += 1
	for j in range(0, len(l)):
		print(l[j], end='')
n = int(input())
year(n)


a = int(input())
b = a
while b >= a:
	b = b + 1
	c = list(str(b))
	if c[0] != c[1] and c[1] != c[2] and (c[2] != c[3]) and (c[0] != c[2]) and (c[0] != c[3]) and (c[1] != c[3]):
		break
d = ''.join(c)
print(d)


n = int(input())
b = 1
while b < 4:
	n = n + 1
	b = len(set(str(n)))
print(n)


n = int(input())
y = True
while y:
	c = str(n + 1)
	if len(set(c)) == 4:
		print(c)
		y = False
	else:
		n += 1


year = input()
test = year
test = int(test) + 1
test = str(test)

def uniqueYear(string):
	for i in range(len(string)):
		for j in range(i + 1, len(string)):
			if string[i] == string[j]:
				return True
	return False
while uniqueYear(test):
	test = int(test) + 1
	test = str(test)
print(test)


def is_nice(x):
	x = str(x)
	set1 = set()
	for i in range(len(x)):
		set1.add(x[i])
	return len(set1) == 4
num = int(input())
num += 1
while not is_nice(num):
	num += 1
print(num)


b = int(input())
a = b + 1
while 1:
	Q = str(a)
	S = set(Q)
	for I in Q:
		S.add(I)
	if len(S) == 4:
		print(a)
		break
	else:
		a += 1


a = int(input())
while True:
	a = a + 1
	count = 0
	b = {}
	for i in str(a):
		if b.get(int(i)):
			count = count + 1
		else:
			b[int(i)] = 1
	if count == 0:
		print(a)
		break


year = input()
n = len(year)
year = int(year) + 1
mark = True
while mark:
	unique = []
	current = year
	for i in range(n):
		if current % 10 in unique:
			year += 1
			mark = True
			break
		else:
			unique.append(current % 10)
			mark = False
			current = current // 10
print(year)


year0 = int(input())

def year1(x):
	x = str(x)
	if x[1] != x[0]:
		if x[2] != x[1] and x[2] != x[0]:
			if x[3] != x[2] and x[3] != x[1] and (x[3] != x[0]):
				return 1
			else:
				return 0
		else:
			return 0
	else:
		return 0
while True:
	year0 += 1
	if year1(str(year0)) == 1:
		break
print(year0)


n = int(input())
i = 1
while True:
	ye = n + i
	l = list(str(ye))
	if len(set(l)) == 4:
		print(ye)
		break
	i += 1


def result(year):
	while True:
		year = str(int(year) + 1)
		if len(set(year)) == 4:
			return year
r = result(input())
print(r)


y = input()
z = int(y)
while True:
	z += 1
	list1 = list(str(z))
	new_list1 = list(set(list1))
	new_list1.sort(key=list1.index)
	if list1 != new_list1:
		continue
	else:
		break
print(z)


from sys import stdin
from math import ceil

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
d = len(str(n))
n += 1
while len(set(str(n))) != d:
	n += 1
print(n)


from math import log10

def check_distinct(n):
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		return True
	else:
		return False

def num_to_list(n):
	d = int(log10(n))
	num = []
	for i in range(d, 0, -1):
		num.append(n // pow(10, i))
		n %= pow(10, i)
	num.append(n)
	return num
year = int(input())
year += 1
while not check_distinct(num_to_list(year)):
	year += 1
print(year)


fy = int(input()) + 1
while len(set(str(fy))) < 4:
	fy = fy + 1
print(fy)


a = input()
b = int(a) + 1
lst = []
a = str(b)
while len(a) != 0:
	lst = []
	for x in a:
		if x not in lst:
			lst.append(x)
	if len(lst) != 4:
		b += 1
		a = str(b)
	else:
		break
print(b)


a = int(input())
dis = False
while dis == False:
	a = a + 1
	b = str(a)
	if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
		dis = True
		break
print(a)


y = int(input())
for t in range(y + 1, 9999):
	x = str(t)
	c = x.count(x[0]) + x.count(x[1]) + x.count(x[2]) + x.count(x[3])
	if c == 4:
		print(t)
		break


def hasrepeated(n):
	s = set(str(n))
	return len(s) == len(str(n))
n1 = int(input())
while 1:
	if hasrepeated(n1 + 1):
		print(n1 + 1)
		break
	else:
		n1 += 1


def ok(x):
	cnt = [0] * 10
	while x:
		if cnt[x % 10]:
			return False
		cnt[x % 10] += 1
		x //= 10
	return True
cand = [_ for _ in filter(ok, range(1000, 9013))]
y = int(input())
for x in cand:
	if x > y:
		print(x)
		break


def check(number):
	value = False
	sequence = tuple(map(int, str(number)))
	x = sequence[0]
	count = 0
	for i in range(len(sequence)):
		for j in range(1, len(sequence)):
			if sequence[i] == sequence[j]:
				count += 1
	return count

def main():
	y = int(input())
	count = 0
	while count != 3:
		y += 1
		count = check(y)
	print(y)
main()


t = int(input()) + 1
while True:
	if len(set(str(t))) == len(str(t)):
		print(t)
		break
	t = t + 1


def beautifulYear(year):
	stryear = str(year)
	if len(set(stryear)) == 4:
		return stryear
	return beautifulYear(year + 1)
year = int(input())
print(beautifulYear(year + 1))


n = input()
for i in range(90000):
	n = int(n)
	n = n + 1
	n = str(n)
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		print(n)
		exit()


l = int(input())
l = l + 1
h = 0
while h == 0:
	if len(str(l)) != len(set(str(l))):
		l = l + 1
	else:
		h = h + 1
print(l)


n = int(input())
x = 1
while True:
	m = n + x
	x = x + 1
	a = m % 10
	b = m // 10 % 10
	c = m // 100 % 10
	d = m // 1000
	if a != b and b != c and (c != d) and (a != c) and (a != d) and (b != d):
		print(m)
		break


y = input()
y = int(y) + 1
for i in range(8000):
	if str(y)[0] == str(y)[1] or str(y)[0] == str(y)[2] or str(y)[0] == str(y)[3] or (str(y)[1] == str(y)[2]) or (str(y)[1] == str(y)[3]) or (str(y)[2] == str(y)[3]):
		y += 1
	else:
		break
print(y)


def isyear(year):
	s = set(str(year))
	if len(s) == 4:
		return 1
	else:
		return 0
year = int(input())
while 1:
	year += 1
	if isyear(year):
		print(year)
		break


y = int(input())
i = 1
s = {}
while True:
	y = y + 1
	k = str(y)
	s = {k[0], k[1], k[2], k[3]}
	if len(s) == 4:
		print(y)
		break


b = int(input())
s = b + 1
a = str(s)
while a[0] == a[1] or a[0] == a[2] or a[0] == a[3] or (a[1] == a[2]) or (a[1] == a[3]) or (a[2] == a[3]):
	s = s + 1
	a = str(s)
print(s)


yy = input()
year = int(yy)
for i in range(year + 1, 9877):
	y = str(i)
	a = int(y[0])
	b = int(y[1])
	c = int(y[2])
	d = int(y[3])
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		break


r = int(input())
for i in range(r + 1, 10001):
	p = str(i)
	p = set(p)
	if len(p) == 4:
		print(i)
		break


n = int(input())
while n >= 0:
	n += 1
	x1 = int(n / 1000)
	x2 = int(n / 100) - 10 * x1
	x3 = int(n / 10) - 10 * x2 - 100 * x1
	x4 = n % 10
	if x1 == x2 or x2 == x3 or x3 == x4 or (x4 == x1) or (x4 == x2) or (x3 == x1):
		continue
	else:
		break
print(n)


def digits(n):
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return True
	return False
n = int(input())
for i in range(n + 1, 9013):
	res = digits(i)
	if res:
		print(i)
		break


y = int(input())
i = 1
while True:
	m = y + i
	a = m // 1000
	b = (m - a * 1000) // 100
	c = (m - a * 1000 - b * 100) // 10
	d = m - a * 1000 - b * 100 - c * 10
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		i += 1
	else:
		break
print(m)


a = int(input())
b = True
count = 0
while b:
	a = a + 1
	a = str(a)
	for i in a:
		if a.count(i) == 1:
			count += 1
	if count == 4:
		b = False
	else:
		count = 0
		a = int(a)
print(a)


def u(l1):
	u1 = []
	for i in l1:
		if i not in u1:
			u1.append(i)
	return u1
t = int(input())
if t == 9000:
	print('9012')
else:
	for i in range(t + 1, 9013):
		i = str(i)
		i = list(i)
		l1 = len(i)
		i = u(i)
		f = ''.join(map(str, i))
		f = int(f)
		if l1 == len(i):
			print(f)
			break


def decide_by(year):
	if len(set(str(year))) == 4:
		return True
a = int(input())
while True:
	a += 1
	if decide_by(a):
		print(a)
		break


from itertools import product
years = []
for comb in product(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], repeat=4):
	if len(set(comb)) == 4 and comb[0] != '0':
		s = ''.join(comb)
		years.append(s)
year = input()
for i in years:
	if i == year:
		print(years[years.index(i) + 1])
		break
	if i > year:
		print(i)
		break


y = input()
check = True
yes = True
yep = True
count = 0
while yep:
	while yes and count < 3:
		count = 0
		cont = True
		y_ = int(y)
		y_ += 1
		y = str(y_)
		for i in range(1, 3):
			if cont:
				for j in range(i + 1, 4):
					if y[i] == y[j]:
						yes = True
						cont = False
						continue
					else:
						count += 1
			else:
				continue
	if y[0] == y[1] or y[0] == y[2] or y[0] == y[3]:
		yes = True
		count = 0
	else:
		print(y)
		yep = False


n = int(input())
x = []
while True:
	n += 1
	x[:] = [int(i) for i in str(n)]
	if len(list(set(x))) == 4:
		print(''.join((str(i) for i in x)))
		break


joop = int(input()) + 1
while len(set(str(joop))) != 4:
	joop += 1
print(joop)


inp = input()
num = int(inp)
while True:
	num += 1
	string = str(num)
	if string.count(string[0]) == 1 and string.count(string[1]) == 1 and (string.count(string[3]) == 1) and (string.count(string[2]) == 1):
		break
print(num)


def duplicates(lst):
	lst = list(str(lst))
	n = len(lst) - 1
	i = 0
	while i < n:
		if lst[i] in lst[i + 1:]:
			del lst[i]
			n -= 1
		i += 1
	return lst
n = input()
n0 = int(n) + 1
while len(duplicates(n0)) < 4:
	n0 += 1
print(n0)


from sys import stdin
year = stdin.readline().rstrip()
i = int(year) + 1
while True:
	num_str = str(i)
	length = len(num_str)
	if len(set(num_str)) == length:
		print(int(num_str))
		break
	else:
		i = int(i) + 1


y = int(input())
y = str(y + 1)
y = list(y)
for i in range(9000):
	if y.count(y[0]) == 1 and y.count(y[1]) == 1 and (y.count(y[2]) == 1) and (y.count(y[3]) == 1):
		break
	y = ''.join(y)
	y = int(y)
	y += 1
	y = list(str(y))
y = ''.join(y)
y = int(y)
print(y)


n = int(input())
while True:
	n += 1
	a = list(str(n))
	lst = []
	for i in a:
		if i not in lst:
			lst.append(i)
	if len(lst) == 4:
		print(n)
		break


from collections import Counter

def checkdistinct(e):
	a = list(str(e))
	b = Counter(a).most_common()[0][1]
	if b == 1:
		return True
	else:
		return False
n = int(input())
for i in range(n + 1, n + 1000000):
	if checkdistinct(i):
		print(i)
		break


def calc(x):
	a = x // 1000
	b = x // 100 % 10
	c = x // 10 % 10
	d = x % 10
	if a != b and b != c and (c != d) and (d != a) and (a != c) and (b != d):
		return True
n = int(input())
ans = n + 1
while True:
	if calc(ans):
		break
	ans += 1
print(ans)


s = input()
if s == '1987':
	print('2013')
else:
	n = int(s)
	for i in range(n + 1, 9500):
		t = str(i)
		m = set()
		for j in t:
			m.add(j)
		if len(m) == 4:
			print(t)
			break


y = int(input())
for i in range(y + 1, 90000):
	if len(set(str(i))) == 4:
		print(i)
		break


def year(a):
	s = set()
	length = len(str(a))
	for i in str(a):
		s.add(i)
	length1 = len(s)
	if length == length1:
		return 1
	else:
		return 0
n = int(input())
true = 1
n += 1
while true:
	if year(n) == 1:
		print(n)
		break
	else:
		n += 1


def distinct(n):
	n = list(str(n))
	for d in n:
		if n.count(d) > 1:
			return False
	return True
n = int(input()) + 1
while not distinct(n):
	n += 1
print(n)


__author__ = 'Utena'
n = int(input())
i = n + 1
while True:
	if len(set(str(i))) == len(str(i)):
		print(i)
		break
	i += 1


y = int(input())

def check(x):
	s = set(str(x))
	if len(s) == len(str(x)):
		return True
	else:
		return False
while True:
	y += 1
	if check(y) == True:
		break
print(y)


y = int(input())
Y = []
y += 1
for x in str(y):
	Y.append(x)

def myfunc():
	n = y
	j = 0
	i = 0
	equal = False
	while i < 4:
		while j < 4:
			if i == j:
				j += 1
				continue
			elif Y[i] == Y[j]:
				n += 1
				Y.clear()
				for x in str(n):
					Y.append(x)
					i = 0
					j = 0
			else:
				equal = True
			j += 1
		j = 0
		i += 1
		if equal == True and i == 3:
			print(n)
			return
myfunc()


x = int(input())
a = x + 1
u = a % 10
d = a // 10 % 10
c = a // 100 % 10
um = a // 1000
while (u == d or u == c or u == um) or (d == c or d == um) or c == um:
	a += 1
	u = a % 10
	d = a // 10 % 10
	c = a // 100 % 10
	um = a // 1000
print(a)


inYearStr = input()
inYear = int(inYearStr)

def isDistinct(year):
	digit = list(str(year))
	digit.sort()
	if digit[0] != digit[1] and digit[1] != digit[2] and (digit[2] != digit[3]):
		return True
	else:
		return False
year = inYear + 1
while not isDistinct(year):
	year = year + 1
print(year)


data = int(input())
while True:
	data += 1
	count = 0
	for x in str(data):
		if str(data).count(x) > 1:
			break
		else:
			count += 1
	if count == len(str(data)):
		print(data)
		break


year = int(input())
while True:
	year += 1
	year_str = str(year)
	digits = list()
	for each in year_str:
		if each not in digits:
			digits.append(each)
	if len(digits) == 4:
		print(year)
		exit(0)


n = int(input())
for i in range(n + 1, 10000):
	res = [int(x) for x in str(i)]
	if len(res) == len(set(res)):
		z = i
		break
print(z)


from sys import stdin

def main():
	n = int(stdin.readline()) + 1
	while True:
		n2 = str(n)
		if n2[0] != n2[1] and n2[0] != n2[2] and (n2[0] != n2[3]) and (n2[1] != n2[2]) and (n2[1] != n2[3]) and (n2[2] != n2[3]):
			print(n2)
			break
		else:
			n += 1
main()


n = int(input())
for i in range(n + 1, 9999):
	a = str(i)
	s = len(set(a))
	if s == 4:
		print(i)
		break


n = int(input())
s = str(n)
x = 1
while x > 0:
	n += 1
	s = str(n)
	if len(set(s)) == len(s):
		print(n)
		break


inp = input()
for x in range(int(inp) + 1, 10000):
	if len(set(str(x))) == len(str(inp)):
		print(x)
		exit()


def isUnique(st):
	if len(st) > 256:
		return False
	char_set = [False] * 128
	for i in range(0, len(st)):
		val = ord(st[i])
		if char_set[val]:
			return False
		char_set[val] = True
	return True

def check(n):
	n = int(n)
	while n <= 9012:
		n += 1
		st = str(n)
		flag = isUnique(st)
		if flag:
			return n

def main():
	n = input()
	ans = check(n)
	print(ans)
main()


y = int(input()) + 1
import itertools as it
for y in it.count(y):
	y = str(y)
	for cmb in it.combinations(y, 2):
		if cmb[0] == cmb[1]:
			break
	else:
		print(y)
		break


n = int(input())
a = []
while n <= 9012:
	n = n + 1
	b = str(n)
	c = list(b)
	d = set(c)
	if len(d) == 4:
		e = list(d)
		n = int(''.join([str(t) for t in c]))
		a.append(n)
	else:
		n = n
print(min(a))


def isUnique(num):
	string = str(num)
	d = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
	for i in string:
		if d[i] == 0:
			d[i] = 1
		elif d[i] == 1:
			return 0
	return 1
string = input()
num = int(string)
while 1:
	num += 1
	if isUnique(num):
		break
print(num)


w = int(input()) + 1
a = 0
while a == 0:
	w = str(w)
	if w.count(w[0]) > 1 or w.count(w[1]) > 1 or w.count(w[2]) > 1 or (w.count(w[3]) > 1):
		w = int(w) + 1
	else:
		a += 1
print(w)


def digRepeat(n):
	s = list(str(n))
	for i in range(0, len(s)):
		for j in range(i + 1, len(s)):
			if s[i] == s[j]:
				return True
				print('hjbjiu')
			else:
				pass
digRepeat(1988)
year1 = int(input())
year2 = 0
while year2 == 0:
	if digRepeat(year1 + 1) == True:
		year1 = year1 + 1
	else:
		year2 = year1
print(year2 + 1)


n = int(input()) + 1
l = list(str(n))
while len(set(l)) != 4:
	n += 1
	l = list(str(n))
print(n)


n = int(input())
while True:
	done = 0
	n += 1
	s = str(n)
	for i in s:
		if s.count(i) == 1:
			done += 1
	if done == 4:
		break
print(n)


n = int(input())

def isDistinct(n):
	n = str(n)
	index = 0
	for c in n:
		index += 1
		if c in n[index:]:
			return False
	return True
n += 1
while not isDistinct(n):
	n += 1
print(n)


n = input()
f = True
while f == True:
	st = ''
	n = int(n) + 1
	n = str(n)
	for j in n:
		if not j in st:
			st += j
			if len(st) == 4:
				print(int(st))
				f = False


n = int(input())
if n < 2013 and n >= 1987:
	print('2013')
else:
	p = n + 1
	while not len(str(p)) == len(set(str(p))):
		p = p + 1
	print(p)


x = int(input(''))
for i in range(x + 1, 9500):
	s = str(i)
	if s[0] != s[1] and s[2] != s[1] and (s[2] != s[0]) and (s[3] != s[2]) and (s[1] != s[3]) and (s[3] != s[0]):
		s1 = int(s)
		print(s1)
		break
	i = i + 1


t = int(input())
t = t + 1
while True:
	s = str(t)
	flag = 0
	for j in s:
		if s.count(j) != 1:
			flag = 1
			break
	if flag == 0:
		break
	t += 1
print(t)


n = int(input()) + 1
for i in range(9000):
	if len(list(set(list(str(n))))) != len(list(str(n))):
		n = n + 1
		continue
	else:
		print(n)
		break


n = int(input(''))
while True:
	flag = 1
	m = n + 1
	m = str(m)
	d = dict()
	for i in m:
		d[i] = d.get(i, 0) + 1
	for i in d:
		if d[i] > 1:
			flag = 0
			break
	if flag == 1:
		print(m)
		break
	n += 1


from collections import *
y = int(input())

def isBeauty(n):
	s = str(n)
	d = defaultdict(lambda : 0)
	for i in range(len(s)):
		if d[s[i]] > 0:
			return False
		d[s[i]] += 1
	return True
while True:
	y += 1
	if isBeauty(y):
		print(y)
		exit(0)


def year(n):
	s = str(n)
	count = 0
	for i in s:
		if s.count(i) == 1:
			count += 1
	if count == len(s):
		return True
	else:
		return False
n = int(input())
while True:
	n = n + 1
	if year(n):
		print(n)
		break
	else:
		continue


n = int(input())
b = 0
while b != 1:
	n = n + 1
	y = n % 10
	d = n // 10 % 10
	s = n // 100 % 10
	h = n // 1000
	if y != d and y != s and (y != h) and (d != s) and (d != h) and (s != h):
		print(n)
		b = 1


year = int(input())
year += 1
while 1:
	y = str(year)
	l = set(y)
	if len(l) != 4:
		year += 1
	else:
		print(year)
		break


def distinct(a):
	b = str(a)
	b = list(b)
	for i in range(0, 3):
		if b.count(b[i]) > 1:
			return 0
	return 1
a = int(input())
while 1:
	a = a + 1
	if distinct(a):
		print(a)
		break


import math
a = []
c = 0
i = 0
j = 0
b = 0
arr = input()
c = int(arr) + 1
while c < 10000:
	k = str(c)
	b = 0
	for i in range(len(k)):
		j = i + 1
		while j < len(k):
			if k[j] != k[i]:
				b += 1
			j += 1
	if b == 6:
		print(c)
		break
	c += 1


year = int(input())
while 1:
	year += 1
	strr = str(year)
	ye = list(set(list(strr)))
	y = len(ye)
	if y == 4:
		k = year
		break
print(year)


def test(s):
	arr = []
	for i in s:
		if i in arr:
			return False
		else:
			arr.append(i)
	return True
n = int(input()) + 1
while not test(str(n)):
	n += 1
print(n)


import sys
sys.setrecursionlimit(20000)

def getlist(tcast):
	return [tcast(x) for x in input().strip().split(' ')]

def getval(tcast):
	return tcast(input().strip())

def getmatrix(r, tcast):
	mat = []
	for i in range(r):
		mat.append(getlist(tcast))
	return mat
start = getval(int) + 1

def uniq(x):
	return len(set(x)) == len(x)
while not uniq(str(start)):
	start += 1
print(start)


year = int(input())
k = True
for i in range(year + 1, 100000):
	years = [int(x) for x in list(str(i))]
	for digit in years:
		if years.count(digit) != 1:
			k = False
	if k == True:
		print(i)
		exit()
	k = True


y = int(input())
for i in range(y + 1, 1000000):
	lst = [i for i in str(i)]
	if len(lst) == len(set(lst)):
		print(i)
		break


year = int(input()) + 1
while True:
	country = str(year)
	allo = list(country)
	if len({*allo}) == 4:
		print(year)
		break
	else:
		year += 1


date = int(input())
nextDate = date
while 1:
	nextDate += 1
	nextDateSet = set()
	for num in str(nextDate):
		nextDateSet.add(num)
	if len(nextDateSet) == 4:
		print(nextDate)
		break


y = input()
x = int(y)
while True:
	i = 0
	x += 1
	y = str(x)
	for j in range(len(str(x))):
		if y.count(y[j]) > 1:
			i += 1
	if i == 0:
		print(x)
		break


def year_count(y):
	is_unique = False
	while not is_unique:
		is_unique = True
		y += 1
		digits = [int(d) for d in str(y)]
		for d in digits:
			if digits.count(d) >= 2:
				is_unique = False
		if is_unique:
			return y
		else:
			continue
print(year_count(int(input())))


year = int(input())
while True:
	year += 1
	yearStr = str(year)
	letters = []
	hasRepeating = False
	for char in yearStr:
		if char in letters:
			hasRepeating = True
			break
		else:
			letters.append(char)
	if not hasRepeating:
		break
print(year)


n = int(input())
for i in range(n + 1, 10000):
	k = i
	l = []
	f = 0
	while k > 0:
		d = k % 10
		if d not in l:
			l.append(d)
		else:
			f = 1
			break
		k = k // 10
	if f == 0:
		print(i)
		break


n = int(input())
while n:
	s = set()
	n += 1
	st = str(n)
	for i in st:
		s.add(i)
	if len(s) == 4:
		print(n)
		break


data = input()
ll = len(data)
k = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
ans = ''
for i in range(1, len(data)):
	mm = data[:i + 1]
	if mm.count(data[i]) > 1:
		data = data[:i + 1]
		break
while data:
	x = int(data[-1])
	if data.count(str(x)) <= 2:
		for i in k[k.count(x):]:
			if i > x and str(i) not in data:
				ans = str(i)
				break
	data = data[:-1]
	if ans:
		break
data = data + ans
if len(data) == ll:
	print(data)
else:
	while len(data) < ll:
		for i in k:
			if str(i) not in data:
				data = data + str(i)
				break
	print(data)


def feduk(a):
	for i in range(a + 1, 9013):
		i = str(i)
		if i[0] != i[1] != i[2] != i[3] and i[1] != i[3] != i[0] != i[2]:
			return i
print(feduk(int(input())))


n = int(input())
n += 1
while True:
	temp = n
	t = []
	ch = 'p'
	while temp > 0:
		x = temp % 10
		if x not in t:
			t.append(x)
		elif x in t:
			ch = 'n'
			break
		temp = temp // 10
	if ch == 'p':
		print(n)
		break
	else:
		n += 1


x = int(input())
for i in range(0, 8000):
	x += 1
	if len(set(list(str(x)))) == 4:
		print(x)
		break


def Counter(a):
	if a.count(a[0]) == a.count(a[1]) and a.count(a[1]) == a.count(a[2]) and (a.count(a[2]) == a.count(a[3]) and a.count(a[3]) == 1):
		return False
	else:
		return True
A = int(input())
A += 1
B = str(A)
while Counter(B):
	A += 1
	B = str(A)
print(B)


def beautifulYear():
	r = int(input()) + 1
	while True:
		if len(set(str(r))) == 4:
			print(r)
			return
		else:
			r = r + 1
beautifulYear()


num = int(input())
i = num + 1
while True:
	numList = list(str(i))
	tempList = []
	counter = 0
	for num in numList:
		if num in tempList:
			break
		else:
			tempList.append(num)
			counter += 1
	if counter == len(numList):
		print(i)
		break
	i += 1


n = input()
b = False
while b != True:
	c = 0
	n = str(int(n) + 1)
	for x in n:
		if n.count(x) != 1:
			c += 1
	if c == 0:
		print(n)
		break


yr = int(input())
for i in range(yr, 10000):
	s = i + 1
	syr = str(s)
	x = set(list(syr))
	if len(x) == 4:
		print(i + 1)
		break


y1 = int(input())
all = list()
for y in range(1000, 10000):
	flag1 = 0
	for i in range(1, 4):
		if str(y)[i] == str(y)[0]:
			flag1 = 1
	flag2 = 0
	for i in range(2, 4):
		if str(y)[i] == str(y)[1]:
			flag2 = 1
	flag3 = 0
	if str(y)[3] == str(y)[2]:
		flag3 = 1
	if flag1 == 0 and flag2 == 0 and (flag3 == 0):
		all.append(y)
if y1 in all:
	th = all.index(y1)
	y2 = all[th + 1]
else:
	all.append(y1)
	all.sort()
	th = all.index(y1)
	y2 = all[th + 1]
print(y2)


y = int(input())
x = y + 1
for i in range(y):
	if len(set(list(str(x)))) == len(list(str(x))):
		print(x)
		break
	else:
		x = x + 1


x = int(input())
x += 1
while True:
	if int(x % 10) != int(x % 100 / 10) and int(x % 10) != int(x % 1000 / 100) and (int(x % 10) != int(x % 10000 / 1000)) and (int(x % 100 / 10) != int(x % 1000 / 100)) and (int(x % 100 / 10) != int(x % 10000 / 1000)) and (int(x % 1000 / 100) != int(x % 10000 / 1000)):
		print(x)
		break
	x += 1


n = int(input())
while True:
	n += 1
	s = str(n)
	r = []
	for i in s:
		r.append(s.count(i))
	if r == [1] * 4:
		print(n)
		break
	else:
		continue


from collections import OrderedDict
x = int(input())
for i in range(x + 1, 10000):
	x = str(i)
	y = ''.join(set(x))
	if len(x) == len(y):
		print(i)
		break


a = input()
c = len(a)
b = int(a) + 1
while True:
	b = str(b)
	if c == len(set(b)):
		print(b)
		exit()
	else:
		b = int(b)
		b = b + 1


def checkdigit(fin):
	final = list(str(fin))
	n = len(final)
	i = 0
	while i < n:
		j = i + 1
		while j < n:
			if final[i] == final[j]:
				return False
			j += 1
		i += 1
	return True
number = int(input())
found = False
final = number + 1
while checkdigit(final) == False:
	final += 1
print(str(final))


from collections import Counter
n = int(input()) + 1
while max(list(Counter(list(str(n))).values())) > 1:
	n = n + 1
print(n)


n = int(input())
s = str(n)
a = 0
while a != 4:
	n = n + 1
	s = str(n)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		a = 4
print(n)


def distinct(n):
	n = str(n)
	a = set({})
	for x in n:
		a.add(x)
	if len(a) == len(n):
		return True
	else:
		return False
n = int(input()) + 1
while True:
	if distinct(n):
		print(n)
		exit()
	n += 1


n = int(input())
while 1:
	n += 1
	l = {n // 1000, n % 1000 // 100, n % 100 // 10, n % 10}
	if len(l) == 4:
		break
print(n)


year = int(input())

def check_year(year):
	lst = [0] * 10
	while year:
		rem = int(year % 10)
		lst[rem] += 1
		if lst[rem] == 2:
			return True
		year = int(year / 10)
	return False
check = True
while check:
	year += 1
	check = check_year(year)
print(year)


def isBeautiful(year):
	for i in range(0, len(year)):
		for j in range(1 + i, len(year)):
			if year[i] == year[j]:
				return False
	return True
year = input()
if int(year) >= 1000 and int(year) <= 9000:
	for i in range(int(year) + 1, 9013):
		if isBeautiful(str(i)):
			print(i)
			break


def isdistinct(n):
	p = set(list(str(n)))
	if len(str(n)) == len(p):
		return True
	else:
		return False
n = int(input())
n = n + 1
while not isdistinct(n):
	n = n + 1
print(n)


x = input()
y = int(x) + 1
n = 0
while n != 1:
	z = str(y)
	if z[0] == z[1] or z[0] == z[2] or z[0] == z[3] or (z[1] == z[2]) or (z[1] == z[3]) or (z[2] == z[3]):
		y += 1
	else:
		print(y)
		n = 1


n = int(input())
for i in range(n + 1, 10000):
	s = str(i)
	if len(s) == len(set(s)):
		print(i)
		exit()


def lista(a):
	al = list()
	al.append(int(a / 1000))
	a -= int(a / 1000) * 1000
	al.append(int(a / 100))
	a -= int(a / 100) * 100
	al.append(int(a / 10))
	a -= int(a / 10) * 10
	al.append(int(a))
	return al
a = int(input())
while 1:
	a += 1
	al = lista(a)
	if al[0] != al[1] and al[0] != al[2] and (al[0] != al[3]) and (al[1] != al[2]) and (al[1] != al[3]) and (al[2] != al[3]):
		break
print(a)


def solve(n: int) -> int:
	if len(set(list(str(n)))) == 4:
		return n
	return solve(n + 1)
n = int(input())
print(solve(n + 1))


n = int(input())
for i in range(90000):
	a = set(str(i))
	if len(str(i)) == len(a) and i > n:
		print(i)
		break


n = int(input()) + 1
for i in range(n, 9013):
	s = str(i)
	T = 0
	for j in range(4):
		if s.count(s[j]) > 1:
			T += 1
	if T == 0:
		print(s)
		break


n = int(input())
for i in range(1, 500):
	l1 = [int(j) for j in str(n + i)]
	if len(list(set(l1))) == 4:
		print(*l1, sep='')
		break


n = int(input())
for i in range(n + 1, 10000):
	j = i
	a = []
	while j:
		a.append(j % 10)
		j = int(j / 10)
	b = set(a)
	if len(a) == len(b):
		print(i)
		break


iny = int(input())
liste = []
while True:
	iny += 1
	a = iny // 1000
	b = iny % 1000 // 100
	c = iny % 100 // 10
	d = iny % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(iny)


year = int(input())
for i in range(year + 1, 9013):
	if i % 10 != i // 1000 and i % 10 != i % 1000 // 100 and (i % 10 != i % 100 // 10) and (i // 1000 != i % 1000 // 100) and (i // 1000 != i % 100 // 10) and (i % 100 // 10 != i % 1000 // 100):
		print(i)
		break


def main():
	n = int(input())
	flag = True
	while flag:
		n += 1
		s = str(n)
		if s[0] == s[1] or s[0] == s[2] or s[0] == s[3] or (s[1] == s[2]) or (s[1] == s[3]) or (s[2] == s[3]):
			continue
		else:
			flag = False
	print(n)
main()


year = input()
for i in range(8000):
	year = int(year)
	year += 1
	year = str(year)
	if year.count(year[0]) == year.count(year[1]) == year.count(year[2]) == year.count(year[3]) == 1:
		break
print(year)


n = int(input())

def per(n):
	s = set()
	while n > 0:
		t = n % 10
		if not t in s:
			s.add(t)
		else:
			return 0
		n //= 10
	return 1
while True:
	n += 1
	if per(n) == 1:
		break
print(n)


def isBeautiful(n):
	return len(set(str(n))) == 4
n = int(input()) + 1
while isBeautiful(n) == False:
	n += 1
print(n)


y = input()
while True:
	c = ''
	y = int(y) + 1
	y = str(y)
	for i in range(len(y)):
		if y.count(y[i]) == 1:
			c += y[i]
	if len(c) == len(y):
		break
print(c)


def is_beautiful(y):
	return len(set(str(y))) == 4

def main():
	y = int(input())
	for x in range(y + 1, 9876):
		if is_beautiful(x):
			print(x)
			return 0
	return -1
main()


def beu_year(num):
	set_d = []
	set_e = []
	while num > 0:
		rem = num % 10
		set_d.append(rem)
		num = int(num // 10)
	for i in set_d:
		if i not in set_e:
			set_e.append(i)
	if len(set_e) == len(set_d):
		return True
	else:
		return False
num = int(input(''))
if beu_year(num + 1) is False:
	while beu_year(num + 1) is not True:
		num += 1
print(num + 1)


in_num = int(input()) + 1
while len(set(str(in_num))) < 4:
	in_num += 1
print(in_num)


def answer():
	a = int(input()) + 1
	while True:
		b = list(str(a))
		worked = 1
		for x in b:
			count = -1
			i = 0
			while i < len(b):
				if b[i] == x:
					count += 1
				i += 1
			if count != 0:
				worked = 0
				break
		if worked:
			j = 0
			ans = ''
			while j < 4:
				ans += str(b[j])
				j += 1
			return int(ans)
		else:
			j = 0
			a = ''
			while j < 4:
				a += str(b[j])
				j += 1
			a = int(a)
			a += 1
print(answer())


n = int(input())
flag = 0
while flag == 0:
	n += 1
	s = str(n)
	se = set(s)
	if len(s) != len(se):
		flag = 0
	else:
		flag = 1
		break
print(n)


n = int(input())
while 1:
	n = n + 1
	st = str(n)
	l = list(st)
	s = set(l)
	l1 = len(l)
	l2 = len(s)
	if l1 == l2:
		print(n)
		break


n = int(input(''))
t = False
while not t:
	n += 1
	for i in range(4):
		for j in range(i + 1, 4):
			if str(n)[i] == str(n)[j]:
				t = True
				break
		if t is True:
			break
	if t is True:
		t = False
	else:
		break
print(n)


y = input()
ifpass = True
while ifpass:
	y = str(int(y) + 1)
	if y.count(y[0]) == 1 and y.count(y[1]) == 1 and (y.count(y[2]) == 1) and (y.count(y[3]) == 1):
		ifpass = False
print(y)


y = int(input())
y += 1
year = str(y)
for i in range(8001):
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]) and (year[1] != year[2]) and (year[1] != year[3]) and (year[2] != year[3]):
		print(y)
		break
	else:
		y += 1
		year = str(y)


y = int(input())
x = []
for i in range(y + 1, 9013):
	i_str = str(i)
	for j in range(0, 4):
		if i_str[j] not in x:
			x.append(i_str[j])
		else:
			x = []
			break
		if len(x) == 4:
			break
	if len(x) == 4:
		break
print(i)


y = int(input())
y = y + 1
while len(set(str(y))) != 4:
	y = y + 1
	while len(set(str(y))) == 4:
		break
print(y)


a = int(input()) + 1
g = True
while g:
	b = len(set(list(str(a))))
	if b == 4:
		g = False
	else:
		a = a + 1
print(a)


def Check(s):
	flag = True
	for i in s:
		if s.count(i) > 1:
			flag = False
			break
	return flag

def Year(s):
	s = str(int(s) + 1)
	while Check(s) is not True:
		s = str(int(s) + 1)
	return s
y = input()
print(Year(y))


year = int(input())
while True:
	year += 1
	s = {year // 1000, year // 100 % 10, year // 10 % 10, year % 10}
	if len(s) == 4:
		print(year)
		break


y = int(input())
while True:
	y += 1
	x = [d for d in str(y)]
	if len(set(x)) == 4:
		print(y)
		break


def isUnique(year):
	D = dict()
	hashList = list()
	while year > 0:
		dig = year % 10
		if dig not in hashList:
			hashList.append(dig)
		else:
			break
		year = year // 10
	if year == 0:
		return True
	else:
		return False
year = int(input())
check = False
while True:
	year = year + 1
	if isUnique(year):
		break
print(year)


def digit(n):
	check = [0] * 4
	x = 3
	while n > 9:
		check[x] += n % 10
		n = n // 10
		x -= 1
	if n <= 9:
		check[0] += n
	mark = [0] * 10
	for i in check:
		mark[i - 1] += 1
		if mark[i - 1] == 2:
			return False
	return True
n = int(input())
while True:
	n += 1
	if digit(n):
		print(n)
		break


n = int(input())
while 1:
	n += 1
	flag = 1
	s = str(n)
	for i in range(0, 4):
		for j in range(i + 1, 4):
			if s[i] == s[j]:
				flag = 0
				break
	if flag == 1:
		print(n)
		break


def isDistinctYear(year):
	digits = dict()
	i = year
	while i > 0:
		digits[i % 10] = 0
		i //= 10
	i = year
	while i > 0:
		digits[i % 10] += 1
		i //= 10
	for i in digits:
		if digits[i] > 1:
			return False
	return True
year = int(input())
distinctYear = False
while distinctYear == False:
	year += 1
	if isDistinctYear(year):
		distinctYear = True
print(year)


n = input()
n1 = int(n)
while True:
	n1 = str(int(n1) + 1)
	l2 = []
	for i in n1:
		l2.append(i)
	l3 = set(l2)
	if len(l2) == len(l3):
		print(n1)
		break


import sys
start = int(sys.stdin.readline())
for year in range(start + 1, 10000):
	if len(set([y for y in str(year)])) == 4:
		print(year)
		break


x = int(input())
while True:
	x = x + 1
	y = str(x)
	t = []
	for i in range(4):
		if y[i] not in t:
			t = t + [y[i]]
	if len(t) == 4:
		break
print(x)


number = input()
number = str(int(number) + 1)

def check(number):
	a = [int(number[i]) for i in range(len(number))]
	return len(a) == len(set(a))
while True:
	if check(number):
		break
	else:
		number = str(int(number) + 1)
print(number)


import sys
year = int(input())
while True:
	year += 1
	a = int(year / 1000)
	b = int(year / 100 % 10)
	c = int(year / 10 % 10)
	d = int(year % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(year)


n = int(input())
i = False
while not i:
	n += 1
	s = str(n)
	e = set(s)
	if len(s) == len(e):
		i = True
print(n)


n = input()
a = int(n)
a += 1
while a < 10000:
	n = str(a)
	m = list(n)
	di1 = m[1] + m[2] + m[3]
	di2 = m[2] + m[3]
	if m[0] in di1 or m[1] in di2 or m[2] == m[3]:
		a += 1
	else:
		print(n)
		break


n = input()
for i in range(int(n), 10001):
	if i > int(n) and len(set(str(i))) == 4:
		print(i)
		break


n = int(input())

def helper(n):
	a = str(n)
	b = list(a)
	c = list(set(b))
	b.sort()
	c.sort()
	return b == c
while helper(n + 1) != 1:
	n += 1
n += 1
print(n)


def diff(x):
	strx = str(x)
	for i in range(0, 10):
		if strx.count(str(i)) > 1:
			return True
	return False
n = int(input()) + 1
while diff(n):
	n = n + 1
print(n)


def year(y):
	res = y + 1
	for i in range(res, 90001):
		aux = 0
		number = list(map(int, str(res)))
		for j in range(len(number)):
			if number.count(number[j]) > 1:
				aux = 1
		if aux == 0:
			print(res)
			return
		else:
			res += 1
y = int(input())
year(y)


def unique(i):
	for (index1, val1) in enumerate(i):
		for (index2, val2) in enumerate(i):
			if val1 == val2 and index1 != index2:
				return False
	return True
i = input()
while True:
	i = str(int(i) + 1)
	if unique(i):
		break
print(i)


x = input()
y = x
list = [chr(x) for x in range(ord('0'), ord('9') + 1)]

def match(x):
	count = 0
	for item in range(len(x)):
		if x.count(x[item]) == 1:
			continue
		else:
			count += 1
	if count == 0:
		return 0
	else:
		return 1
while True:
	x = str(int(x) + 1)
	if match(x) == 0:
		break
print(x)


y = int(input())
y += 1
y_string = str(y)
invalid = True
while invalid:
	y_sorted = ''.join(sorted(y_string))
	invalid = False
	for i in range(len(y_sorted) - 1):
		if y_sorted[i] == y_sorted[i + 1]:
			invalid = True
	if invalid:
		y += 1
		y_string = str(y)
print(y)


def dis(n):
	l = list(set(str(n)))
	if len(l) == 4:
		return 1
	return 0
n = int(input()) + 1
while 1:
	if dis(n) == 1:
		break
	n += 1
print(n)


while True:
	try:
		y = input()
		y = int(y)
		while True:
			y += 1
			num = []
			for i in range(0, 10):
				num += [0]
			temp = y
			for i in range(0, 4):
				num[int(temp % 10)] += 1
				temp /= 10
			flag = True
			for i in range(0, 10):
				if num[i] > 1:
					flag = False
			if flag:
				print(y)
				break
	except EOFError:
		break


y = int(input())
s = str(y)
c = 1
i = 1
while i > 0:
	l = list(str(y + c))
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
		i = 0
	c += 1
print(y + c - 1)


from collections import Counter

def is_beautiful_year(year_as_list):
	for i in year_as_list:
		if i > 1:
			return False
	return True

def solve_the_problem():
	year = int(input())
	while True:
		year += 1
		counts = [int(x) for x in Counter(list(str(year))).values()]
		if is_beautiful_year(counts):
			print(year)
			return
solve_the_problem()


y = int(input())
while True:
	y += 1
	y1 = str(y)
	yy = list(y1)
	tt = set(yy)
	if len(tt) == len(yy):
		print(y)
		break


def isbeautiful(y):
	c = 0
	y = str(y)
	for i in range(len(y)):
		if y.count(y[i]) == 1:
			c = c + 1
	if len(y) == c:
		return True
	else:
		return False
s = int(input())
y = s + 1
while y:
	if isbeautiful(y):
		print(y)
		break
	else:
		y = y + 1


year = int(input())
while True:
	year += 1
	q = year // 1000 % 10
	w = year // 100 % 10
	e = year // 10 % 10
	r = year % 10
	if q != w and q != e and (q != r) and (w != e) and (w != r) and (e != r):
		break
print(year)


def check():
	s = str(n)
	a = [0] * 10
	for i in range(4):
		if a[int(s[i])] == 0:
			a[int(s[i])] = 1
		else:
			return False
	return True
n = int(input()) + 1
while not check():
	n += 1
print(n)


while True:
	try:

		class Decode:

			def __init__(self, s=''):
				self.s = s

			def inputt(self):
				self.s = int(input())

			def solve(self):
				year = self.s + 1
				while len(set(str(year))) != 4:
					year += 1
				print(year)
		if __name__ == '__main__':
			obj = Decode()
			obj.inputt()
			obj.solve()
	except EOFError:
		break


year = input()
stop = True
resultYear = int(year)
while stop:
	resultYear = int(resultYear) + 1
	val = list(set(str(resultYear)))
	if len(val) == 4:
		resultYear = resultYear
		stop = False
print(resultYear)


def main():
	number = int(input())
	out = 0
	while out == 0:
		number += 1
		listNumbers = [int(x) for x in str(number)]
		listNumbers = set([x for x in listNumbers if listNumbers.count(x) > 1])
		if not listNumbers:
			out = 1
	print(number)
main()


y = int(input())
while y < 10000:
	y += 1
	if len(set(str(y))) == len(str(y)):
		print(y)
		break


n = input()
c = 0
temp = str(int(n))
while c != 1:
	temp = str(int(temp) + 1)
	if temp[0] != temp[1] and temp[0] != temp[2] and (temp[0] != temp[3]) and (temp[1] != temp[2]) and (temp[1] != temp[3]) and (temp[2] != temp[3]):
		c = c + 1
print(temp)


a = int(input())
b = a + 1
while b > a:
	if len(str(b)) == len(set(str(b))):
		print(b)
		break
	else:
		b = b + 1


a = int(input())
flag1 = 0
while flag1 == 0:
	a += 1
	dig = []
	dig2 = set()
	n = a
	if n < 10:
		dig.append(n % 10)
		n // 10
	while n // 10 > 0:
		dig.append(n % 10)
		n = n // 10
		if n // 10 == 0:
			dig.append(n)
	for i in range(len(dig)):
		dig2.add(dig[i])
	if len(dig) == len(dig2):
		flag1 = 1
print(a)


a = int(input())
a = a + 1
if len(set(str(a))) == 4:
	print(a)
else:
	while len(set(str(a))) != 4:
		a = a + 1
	print(a)


a = int(input())
while True:
	a += 1
	b = a
	lst = []
	for _ in range(len(str(b))):
		lst.append(b % 10)
		b = int(b / 10)
	lst2 = []
	for _ in lst:
		if _ not in lst2:
			lst2.append(_)
	if len(lst2) == len(lst):
		print(a)
		break


def jud(n):
	s = str(n)
	a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in s:
		a[ord(i) - 48] += 1
	for i in range(10):
		if a[i] >= 2:
			return False
	return True
n = int(input())
n += 1
while not jud(n):
	n += 1
print(n)


n = int(input())
e = n
for i in range(n + 1, 10000):
	N = list(str(i))
	a0 = N.count('0')
	if a0 >= 1:
		a0 = 1
	a1 = N.count('1')
	if a1 >= 1:
		a1 = 1
	a2 = N.count('2')
	if a2 >= 1:
		a2 = 1
	a3 = N.count('3')
	if a3 >= 1:
		a3 = 1
	a4 = N.count('4')
	if a4 >= 1:
		a4 = 1
	a5 = N.count('5')
	if a5 >= 1:
		a5 = 1
	a6 = N.count('6')
	if a6 >= 1:
		a6 = 1
	a7 = N.count('7')
	if a7 >= 1:
		a7 = 1
	a8 = N.count('8')
	if a8 >= 1:
		a8 = 1
	a9 = N.count('9')
	if a9 >= 1:
		a9 = 1
	if a1 + a2 + a3 + a4 + a5 + a6 + a7 + a9 + a8 + a0 == 4:
		e = i
		break
print(e)


n = int(input())
i = n + 1
while 1:
	l = []
	s = str(i)
	for j in s:
		if j not in l:
			l.append(j)
	if len(l) == 4:
		print(i)
		break
	else:
		i = i + 1


def check(x):
	n1 = x // 1000
	n2 = x // 100 % 10
	n3 = x // 10 % 10
	n4 = x % 10
	return n1 != n2 and n1 != n3 and (n1 != n4) and (n2 != n3) and (n2 != n4) and (n3 != n4)
y = int(input())
res = y + 1
while not check(res):
	res += 1
print(res)


a = int(input())
c = a
while c < 10000:
	c = c + 1
	if c // 1000 != c // 100 % 10 and c // 1000 != c // 10 % 10 and (c // 1000 != c % 10) and (c // 100 % 10 != c // 10 % 10) and (c // 100 % 10 != c % 10) and (c // 10 % 10 != c % 10):
		print(c)
		break


def check_distinct_digit(y):
	digit = []
	flag = True
	while y > 0:
		d = y % 10
		y = y // 10
		if d not in digit:
			digit.append(d)
		else:
			flag = False
			break
	return flag
y = int(input())
while True:
	y = y + 1
	if check_distinct_digit(y):
		print(y)
		break


stra = input()
inta = int(stra)
while 1:
	inta += 1
	stra = str(inta)
	if len(stra) == len(set(stra)):
		print(stra)
		exit(0)


y = int(input())
y1 = ['0', '0', '0', '0']
y = y + 1
while y <= 100000:
	y1[0] = int(y / 1000)
	y1[1] = int(int(y / 100) % 10)
	y1[2] = int(int(y / 10) % 10)
	y1[3] = int(y % 10)
	if y1[0] != y1[1] and y1[0] != y1[2] and (y1[0] != y1[3]) and (y1[1] != y1[2]) and (y1[1] != y1[3]) and (y1[2] != y1[3]):
		print(y)
		break
	else:
		y = y + 1


a = input()
b = ''
while True:
	a = int(a)
	a += 1
	a = str(a)
	f = 0
	b = ''
	for x in a:
		if x not in b:
			b += x
		else:
			break
	if len(b) == 4:
		break
print(b)


year = int(input())
unique = False
while not unique:
	unique = True
	year += 1
	for i in range(len(str(year))):
		if str(year)[i] in str(year)[:i] + str(year)[i + 1:]:
			unique = False
print(year)


year = int(input()) + 1
flag = True
while flag:
	stYear = str(year)
	for i in range(len(stYear)):
		if stYear.count(stYear[i]) > 1:
			year += 1
			break
		elif i == len(stYear) - 1:
			flag = False
print(year)


y = int(input()) + 1
t = 0
while t != 4:
	a = list(str(y))
	a1 = a.count(a[0])
	a2 = a.count(a[1])
	a3 = a.count(a[2])
	a4 = a.count(a[3])
	t = a1 + a2 + a3 + a4
	y += 1
else:
	print(y - 1)


t = int(input())
while True:
	t += 1
	k = list(str(t))
	l = set(k)
	if len(l) == len(k):
		for i in k:
			print(i, end='')
		break


value = int(input())
while True:
	value += 1
	values = str(value)
	if len(set(values)) == 4:
		print(value)
		break


n = input()
list_n = list(map(int, n))
list_count = list(dict.fromkeys(list_n))
while len(list_count) <= len(list_n) + 1:
	n = int(n) + 1
	n = str(n)
	list_n = list(map(int, n))
	list_count = list(dict.fromkeys(list_n))
	if len(list_count) == len(list_n):
		print(n)
		break
else:
	print(int(n))


def isdistinct(n):
	d = {}
	c = 0
	while n > 0:
		r = n % 10
		n = n // 10
		d[r] = 0
		c += 1
	if c == len(list(d.keys())):
		return True
	else:
		return False
n = int(input())
i = n + 1
while True:
	if isdistinct(i):
		break
	i = i + 1
print(i)


s = input()

def all_diff(x):
	return len(set(x)) == 4
curr = int(s)
curr += 1
while not all_diff(str(curr)):
	curr += 1
print(curr)


n = int(input())
is_different = lambda x: len(set(str(x))) == 4
n += 1
while not is_different(n):
	n += 1
print(n)


x = int(input()) + 1
for i in range(x, 1 << 31):
	if len(set(str(i))) == 4:
		print(i)
		break


def solve(y):
	while True:
		y += 1
		k = list(str(y))
		if len(set(k)) == len(k):
			return y

def main():
	y = int(input())
	print(solve(y))
main()


x = int(input())
if x >= 1000 and x <= 9000:
	x = x + 1
	while x:
		n = x
		l = []
		while n > 0:
			y = n % 10
			l.append(y)
			n = n // 10
		ln = len(l)
		s = set(l)
		sn = len(s)
		if ln == sn:
			print(x)
			break
		else:
			x = x + 1


num = input()
while True:
	temp = int(num)
	temp += 1
	num = str(temp)
	lst = list(num)
	if len(list(set(lst))) == len(lst):
		print(num)
		break


def distinct(num: int) -> bool:
	digits = []
	while num > 0:
		digit = num % 10
		if digit in digits:
			return False
		digits.append(digit)
		num //= 10
	return True
year = int(input()) + 1
while not distinct(year):
	year += 1
print(year)


n = input()
i = 1
result = str(int(n) + i)
while result[0] == result[1] or result[0] == result[2] or result[0] == result[3] or (result[1] == result[2]) or (result[1] == result[3]) or (result[2] == result[3]):
	i += 1
	result = str(int(n) + i)
print(result)


y = int(input())
for i in range(y + 1, 9100):
	a = set()
	t = i
	for j in range(4):
		b = i % 10
		a.add(b)
		i //= 10
	if len(a) > 3:
		print(t)
		break


n = input()
n1 = list(n)
i = int(n)
while True:
	i += 1
	if len(set(list(str(i)))) == 4:
		print(i)
		break


def solve(n):
	a = n % 10
	b = int(n / 10) % 10
	c = int(n / 100) % 10
	d = int(n / 1000) % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return 1
	else:
		return 0
z = int(input())
y = z
while 1:
	y += 1
	x = solve(y)
	if x == 1:
		print(y)
		break


def raz(s):
	if len(set(s)) == len(s):
		return True
	else:
		return False
n = int(input())
for x in range(n + 1, 100000):
	if raz(str(x)):
		print(x)
		exit(0)


n = int(input())
for i in range(n, 9500):
	i += 1
	(b, c, d, e) = (i % 10, int(i / 10) % 10, int(i / 100) % 10, int(i / 1000) % 10)
	if b != c and b != d and (b != e) and (c != d) and (c != e) and (d != e):
		break
print(i)


def diff(s):
	s = str(s)
	x = list(s)
	y = set(s)
	if len(y) < len(x):
		return 0
	else:
		return 1
t = int(input()) + 1
while 1:
	if diff(t) == 1:
		print(t)
		break
	else:
		t = t + 1


def checksame(n):
	strdig = str(n)
	if strdig[0] == strdig[1] or strdig[0] == strdig[2] or strdig[0] == strdig[3] or (strdig[1] == strdig[2]) or (strdig[1] == strdig[3]) or (strdig[2] == strdig[3]):
		return False
	else:
		return True
n = int(input())
solved = False
while solved == False:
	n += 1
	digitarray = str(n)
	if checksame(digitarray):
		print(n)
		solved = True


inp = input()
num = int(inp)
while True:
	num = num + 1
	if len(set(str(num))) == len(inp):
		print(num)
		break


a = int(input())
for a in range(a + 1, 90000):
	u = a % 10
	d = a // 10 % 10
	c = a // 100 % 10
	m = a // 1000
	if (u != d and u != c) and (u != m and d != c) and (d != m and m != c):
		print(a)
		break


def check(year):
	count = 0
	for c_1 in year:
		for c_2 in year:
			if c_1 == c_2:
				count = count + 1
	if count == 4:
		return True
	else:
		return False
year = input()
while True:
	year = str(int(year) + 1)
	if check(year):
		print(year)
		exit()


x = int(input())
y = x + 1
c = 1
while c != 0:
	c = 0
	r = str(y)
	r = list(r)
	for i in range(0, len(r)):
		for j in range(i + 1, len(r)):
			if r[i] == r[j]:
				c += 1
	y = y + 1
print(y - 1)


a = input('')
a = str(int(a) + 1)
i = 0
while True:
	if a[i:i + 1] != a[i + 1:i + 2] and a[i:i + 1] != a[i + 2:i + 3] and (a[i:i + 1] != a[i + 3:i + 4]) and (a[i + 1:i + 2] != a[i + 2:i + 3]) and (a[i + 1:i + 2] != a[i + 3:i + 4]) and (a[i + 2:i + 3] != a[i + 3:i + 4]):
		print(a)
		break
	else:
		a = str(int(a) + 1)
		continue


def main():
	ye = int(input())
	c = 0
	i = ye + 1
	while ye >= 1000 and ye <= 9000:
		l = list(str(i))
		l.sort()
		for j in range(3):
			if l[j] == l[j + 1]:
				c += 1
		if c == 0:
			print(i)
			break
		l.clear()
		c = 0
		i += 1
main()


year = int(input())
year += 1
while True:
	y = str(year)
	if y[0] == y[1] or y[0] == y[2] or y[0] == y[3] or (y[1] == y[2]) or (y[1] == y[3]) or (y[2] == y[3]):
		year += 1
	else:
		break
print(year)


num = int(input())
init = num + 1
while True:
	l = list(map(int, str(init)))
	if len(dict.fromkeys(l)) > 3:
		print(init)
		break
	init += 1


N = input()

def areDistinct(i):
	i = str(i)
	b = Convert(i)
	n = len(b)
	s = set()
	for i in range(0, n):
		s.add(b[i])
	return len(s) == len(b)

def Convert(string):
	list1 = []
	list1[:0] = string
	return list1

def infinity():
	i = int(N)
	while True:
		i += 1
		yield i
for i in infinity():
	if areDistinct(i) and i > int(N):
		print(i)
		break


x = int(input())
while len(set(str(x + 1))) <= 3:
	x += 1
print(x + 1)


import sys
y = int(input())

def check(year):
	sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for num in str(year):
		sums[int(num)] += 1
	return sum([1 for i in sums if i not in [0, 1]]) == 0
for i in range(y + 1, 9013):
	if check(i):
		print(i)
		break


def by(y):
	while True:
		y = int(y) + 1
		y = str(y)
		if sorted(list(set(y))) == sorted(list(y)):
			break
	return y
y = input()
print(by(y))


y = int(input())
for k in range(y + 1, 10000):
	if len(set(str(k))) == 4:
		break
print(k)


def run(y):
	if y[1] != y[2] and y[2] != y[3] and (y[2] != y[0]) and (y[1] != y[3]) and (y[1] != y[0]) and (y[3] != y[0]):
		print(y)
	else:
		run(str(int(y) + 1))

def main():
	y = input()
	run(str(int(y) + 1))
main()


year = int(input())
while True:
	year += 1
	test = list(str(year))
	test.sort()
	ok = True
	for i in range(1, len(test)):
		if test[i] == test[i - 1]:
			break
	else:
		print(year)
		break


y = input()
cs = int(y)
while 1:
	cs = int(cs)
	cs = cs + 1
	cs = str(cs)
	l = len(set(cs))
	if l == 4:
		by = cs
		break
print(by)


def minimum_distinct_year(year):
	is_distinct = False
	distinct_year = year
	while not is_distinct:
		distinct_year += 1
		if is_unique(distinct_year):
			return distinct_year

def is_unique(num):
	same_digit = {}
	while num > 0:
		temp = num % 10
		num //= 10
		if temp in same_digit:
			return False
		same_digit[temp] = True
	return True

def main():
	year = int(input())
	print(minimum_distinct_year(year))
main()


def check(n):
	while True:
		n = str(int(n) + 1)
		if len(set(n)) == 4:
			print(n)
			break
x = input()
check(x)


year = int(input())
lisyear = []
[lisyear.append(i) for i in str(year)]
for i in range(1000, 9020):
	if year < i:
		if len(str(i)) == len(set(str(i))):
			print(i)
			break


y = int(input())
for z in range(1000, 10000):
	n = 0
	for i in range(1, len(str(z))):
		if sorted(list(str(z)))[i] == sorted(list(str(z)))[i - 1]:
			n += 1
	if z > y and n == 0:
		print(z)
		break


year = int(input()) + 1

def update(year, idx):
	exp = 3 - idx
	return int((year // 10 ** exp + 1) * 10 ** exp)

def unique(s):
	seen = set([])
	for (i, char) in enumerate(s):
		if char in seen:
			return i
		seen.add(char)
	return 0
idx = unique(str(year))
while idx:
	year = update(year, idx)
	idx = unique(str(year))
print(year)


y = int(input())
x = y + 1
while x:
	x = str(x)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		print(x)
		break
	x = int(x) + 1


op = int(input())
op = op + 1
while len(str(op)) != len(set(str(op))):
	op = op + 1
print(op)


year = int(input())
for i in range(1, 1000):
	year += 1
	lists = list(str(year))
	if len(lists) == len(set(lists)):
		break
print(year)


year = int(input())
year += 1
yearlist = list(str(year))
while not (yearlist[0] != yearlist[1] != yearlist[2] != yearlist[3] != yearlist[0] != yearlist[2] and yearlist[1] != yearlist[3]):
	year += 1
	yearlist = list(str(year))
print(int(year))


def isGood(x):
	a = x // 1000
	b = (x % 1000 - x % 100) // 100
	c = (x % 100 - x % 10) // 10
	d = x % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return True
	else:
		return False
n = int(input())
n += 1
while True:
	if isGood(n):
		print(n)
		break
	else:
		n += 1


def fun(n):
	c = 0
	d = {}
	while n != 0:
		c += 1
		d[n % 10] = d.get(n % 10, 0) + 1
		n = n // 10
	if len(d.keys()) == c:
		return False
	else:
		return True
n = int(input())
n += 1
while fun(n):
	n += 1
print(n)


n = input()
sol = int(n) + 1
while len(set(str(sol))) < 4:
	sol += 1
print(sol)


a = int(input())
a += 1
d = [i for i in str(a)]
while len(set(d)) != len(d):
	a += 1
	d = [i for i in str(a)]
print(*d, sep='')


from collections import Counter
year = int(input())
li = []
while True:
	year = year + 1
	year1 = list(str(year))
	year2 = [v for (f, v) in Counter(year1).items()]
	if sum(year2) == len(year2):
		print(year)
		break


def is_distinct(year):
	numbers = set()
	year = str(year)
	for letter in year:
		numbers.add(letter)
	return len(numbers) == len(year)
year = int(input())
while True:
	year += 1
	if is_distinct(year):
		print(year)
		break


x = input()
a = int(x)
for i in range(a + 1, 10000):
	n = list(str(i))
	c = 0
	for x in range(4):
		for y in range(x, 4):
			if n[x] != n[y]:
				c += 1
	if c == 6:
		print(i)
		break


year = str(input())
from collections import Counter
y = Counter(year)
y2 = int(year)
while True:
	y2 = y2 + 1
	if len(set(str(y2))) < 4:
		continue
	else:
		print(y2)
		break


n = int(input())
for i in range(n + 1, 90000):
	x = i
	a = x // 1000
	x = x - a * 1000
	b = x // 100
	x = x - b * 100
	c = x // 10
	x = x - c * 10
	if a != b and a != c and (a != x) and (b != c) and (b != x) and (c != x):
		print(i)
		break


def isdistinct(y):
	l = []
	while y > 0:
		if y % 10 not in l:
			l.append(y % 10)
		else:
			return False
		y = y // 10
	return True
y = int(input())
while True:
	y = y + 1
	if isdistinct(y):
		break
print(y)


y = int(input()) + 1
while True:
	y = str(y)
	t = 0
	for i in range(10):
		i = str(i)
		if i in y:
			t += 1
	if t == 4:
		print(y)
		break
	else:
		y = int(y)
		y += 1


def distinct(year):
	for i in range(len(year)):
		s = year[:i] + year[i + 1:]
		if year[i] in s:
			return False
	return True
year = int(input())
for y in range(year + 1, 9013):
	if distinct(str(y)):
		print(y)
		break


n = int(input())
c = n + 1
ans = n
f = set()
while 1:
	k = c
	while k:
		f.add(k % 10)
		k = k // 10
	if len(f) == 4:
		ans = c
		break
	else:
		c += 1
		f.clear()
print(ans)


n = int(input())
c = 0
while c != 1:
	n = n + 1
	l = []
	for i in str(n):
		l.append(i)
	x = set(l)
	if len(x) == 4:
		print(n)
		c = 1


from collections import Counter
year = int(input()) + 1
while True:
	val = str(year)
	if len(Counter(val)) == 4:
		print(int(val))
		break
	year += 1


n = int(input())
if n >= 1000 and n <= 9000:
	for i in range(n + 1, 9013):
		if len(set(str(i))) == len(str(i)):
			print(int(i))
			break


x = int(input())
x += 1
q = 0
while x < 10000:
	for i in str(x):
		for n in str(x):
			if i == n:
				q += 1
	if q == 4:
		print(x)
		break
	else:
		q = 0
		x += 1


from collections import Counter
n = int(input()) + 1
while 1:
	s = str(n)
	k = Counter(s)
	if len(k) == len(s):
		print(s)
		break
	n += 1


def is_distinct(year):
	for i in year:
		if year.count(i) > 1:
			return False
	return True
year = input()
int_year = int(year)
while True:
	int_year += 1
	if is_distinct(str(int_year)):
		print(int_year)
		break


y = input()

def c(n):
	k = str(n)
	for i in range(len(k) - 1):
		if k[i] in k[i + 1:]:
			return False
	return True
k = int(y) + 1
while True:
	if not c(k):
		k += 1
	else:
		break
print(k)


y = input()
year = str(int(y) + 1)
z = ''.join(set(year))
while len(z) != 4:
	year = int(year) + 1
	yearstr = str(year)
	z = ''.join(set(yearstr))
print(year)


def check(year):
	year = str(year)
	return len(year) == len(set(year))
for year in range(int(input()) + 1, 100000):
	if check(year):
		print(year)
		break


x = int(input())
for i in range(x + 1, 9013):
	f = [0] * 10
	g = i % 10
	f[g] = 1
	s = i // 10 % 10
	f[s] = 1
	b = i // 100 % 10
	f[b] = 1
	q = i // 1000
	f[q] = 1
	if sum(f) == 4:
		print(i)
		exit()
	else:
		continue


s = int(input())
flag = False
while flag == False:
	flag = True
	a = []
	s += 1
	for i in range(len(str(s))):
		a.append(str(s)[i])
	a.sort()
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			flag = False
print(s)


def main():
	y = int(input()) + 1
	while y <= 9012:
		if isDifferent(y):
			print(y)
			break
		y = y + 1

def isDifferent(year):
	number = year
	d0 = number // 1000
	number = number % 1000
	d1 = number // 100
	number = number % 100
	d2 = number // 10
	d3 = number % 10
	if d0 != d1 and d0 != d2 and (d0 != d3) and (d1 != d2) and (d1 != d3) and (d2 != d3):
		return True
	else:
		return False
main()


n = int(input())
n = n + 1
if n - 1 >= 1000 and n - 1 <= 9000:
	for s in range(n, 9013):
		y = s
		l = set()
		while s > 0:
			x = s % 10
			s = s // 10
			l.add(x)
		if len(l) == 4:
			print(y)
			break
		else:
			l.clear()


i = int(input())
i += 1
while len(set(list(str(i)))) < 4:
	i += 1
print(i)


def check_input(y):
	while y < 1000 or y > 9000:
		y = int(input())
	return y

def executee(y):
	test = False
	i = y + 1
	s = str(i)
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	d = int(s[3])
	while test == False:
		s = str(i)
		a = int(s[0])
		b = int(s[1])
		c = int(s[2])
		d = int(s[3])
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			test = True
		else:
			i += 1
	return i
y = int(input())
y = check_input(y)
i = executee(y)
print(i)


s = int(input())
t = s + 1
while True:
	lst = set(list(str(t)))
	if len(lst) == 4:
		print(t)
		break
	else:
		t += 1


year = input()
isDistinct = False
while not isDistinct:
	isDistinct = True
	year = str(int(year) + 1)
	for i in year:
		if year.count(i) > 1:
			isDistinct = False
			break
print(year)


y = input()
for i in range(int(y) + 1, 9050):
	y = str(i)
	if y[0] == y[1]:
		continue
	elif y[0] == y[2]:
		continue
	elif y[0] == y[3]:
		continue
	elif y[1] == y[2]:
		continue
	elif y[1] == y[3]:
		continue
	elif y[2] == y[3]:
		continue
	else:
		print(i)
		break


numbers_of_year = int(input()) + 1
while len(set(str(numbers_of_year))) != 4:
	numbers_of_year += 1
print(numbers_of_year)


n = int(input())
while True:
	n += 1
	s = str(n)
	c = 0
	for i in s:
		if s.count(i) > 1:
			c = 1
	if c == 0:
		print(n)
		break


n = input()
next = int(n) + 1
while True:
	if len(set(str(next))) == len(n):
		print(next)
		break
	else:
		next += 1


oyear = input()
year = int(oyear)
ylist = list(oyear)
while True:
	year += 1
	nylist = list(str(year))
	if sorted(list(set(nylist))) == sorted(nylist):
		print(year)
		break


t = input()
has = [0] * 10
t = int(t)
t = t + 1
t = str(t)
while True:
	has = [0] * 10
	for x in t:
		has[int(x)] = has[int(x)] + 1
	if has.count(1) == 4:
		print(t)
		break
	else:
		t = int(t)
		t = t + 1
		t = str(t)


test = str(input())
for i in range(int(test) + 1, 10000):
	x = str(i)
	one = int(x[0])
	two = int(x[1])
	three = int(x[2])
	four = int(x[3])
	if one != two and one != three and (one != four) and (two != three) and (two != four) and (three != four):
		print(x)
		break


year = int(input())
for y in range(year + 1, 9013):
	y = str(y)
	if y.count(y[0]) == 1 and y.count(y[1]) == 1 and (y.count(y[2]) == 1) and (y.count(y[3]) == 1):
		print(y)
		break


a = int(input())

def beautiful_year(year):
	checker = []
	year = str(year)
	for el in year:
		if el in checker:
			break
		else:
			checker.append(el)
	else:
		return 'yes'
next_year = a + 1
while not beautiful_year(next_year):
	next_year += 1
print(next_year)


n = int(input())
for i in range(n + 1, 9013):
	if len(set(list(str(i)))) == 4:
		print(i)
		exit()


def beautifulYear(n):
	m = []
	for digit in str(n):
		m.append(int(digit))
	numbers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in range(4):
		numbers[m[i]] = numbers[m[i]] + 1
	for i in range(10):
		if numbers[i] >= 2:
			return False
	return True
n = int(input())
n = n + 1
while beautifulYear(n) != True:
	n = n + 1
print(n)


n = int(input())
k = str(n)
while True:
	if int(k) > n and sorted(k) == sorted(set(k)):
		break
	else:
		k = int(k) + 1
		k = str(k)
print(k)


year = int(input()) + 1
for i in range(1000):
	l = list(str(year))
	if l[0] != l[1] != l[2] != l[3] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[3]):
		break
	else:
		year += 1
print(year)


def numDigitsDiffer(num):
	num = list(str(num))
	for digit in num:
		if num.count(digit) > 1:
			return False
	return True
a = int(input()) + 1
while not numDigitsDiffer(a):
	a = int(a) + 1
print(a)


n = int(input())
for i in range(n + 1, 18001):
	if len(list(str(i))) == len(set(list(str(i)))):
		print(i)
		exit()


def check_duplicates(year):
	sorted_year = sorted(str(year))
	duplicated_digits = False
	for i in range(len(sorted_year) - 1):
		if sorted_year[i] == sorted_year[i + 1]:
			duplicated_digits = True
			break
	return duplicated_digits
last_year = int(input()) + 1
find_it = 0
while find_it == 0:
	is_duplicated = check_duplicates(last_year)
	if is_duplicated:
		last_year = last_year + 1
	else:
		find_it = find_it + 1
print(last_year)


previous = int(input())
while True:
	later = previous + 1
	laterlist = list(str(later))
	cleanlist = []
	for i in laterlist:
		if i not in cleanlist:
			cleanlist.append(i)
	if laterlist == cleanlist:
		print(later)
		break
	else:
		previous += 1
		continue


from collections import Counter
n = int(input())
a = n + 1
count = 1
while count:
	s = str(a)
	b = [x for x in s]
	c = len(Counter(b).keys())
	if c == len(b):
		print(s)
		count = 0
		break
	else:
		a = a + 1


n = int(input())
a = n % 10
b = n % 100 // 10
c = n % 1000 // 100
d = n % 10000 // 1000
s = set()
while len(s) < 4:
	a = a + 1
	if a == 10:
		a = 0
		b = b + 1
		if b == 10:
			b = 0
			c = c + 1
			if c == 10:
				c = 0
				d = d + 1
	s = {a, b, c, d}
print(int(str(d) + str(c) + str(b) + str(a)))


import re

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def distinct(n):
	for i in n:
		if n.count(i) > 1:
			return False
	return True

def ntol(n):
	a = []
	while n > 0:
		x = n % 10
		a.append(x)
		n //= 10
	return a
n = inp()
i = n + 1
while True:
	if distinct(ntol(i)) == True:
		print(i)
		break
	else:
		i += 1


s = input()
year = int(s) + 1
s = str(year)
cnt = 0
while cnt != 4:
	cnt = 0
	for i in range(4):
		if s[i] not in s[i + 1:]:
			cnt += 1
		else:
			break
	year += 1
	s = str(year)
print(year - 1)


year = input()
year_val = list(year)
i = int(year) + 1
while True:
	save_val = list(str(i))
	save = set(save_val)
	if len(save) == len(year_val):
		print(''.join(save_val))
		break
	i += 1


y = int(input())
i = 0
while i != 1:
	y = y + 1
	u = str(y)
	u = set(u)
	if len(u) == 4:
		i = 1
		print(y)
		break


y = input()

def distinct(y):
	d = {}
	for i in y:
		if i in d.keys():
			return False
		else:
			d[i] = 1
	return True
y = str(int(y) + 1)
while not distinct(y):
	y = str(int(y) + 1)
print(y)


c = int(input()) + 1
y = set(str(c))
while len(y) < 4:
	c = c + 1
	y = set(str(c))
print(c)


y = int(input())
m = y
while True:
	m = m + 1
	x = str(m)
	set1 = set(list(x))
	n = len(set1)
	if m > y and n == 4:
		print(int(m))
		break


y = int(input())
y = y + 1

def isDistinct(year):
	sy = str(year)
	li = []
	for i in sy:
		if i in li:
			return False
		li.append(i)
	return True
while not isDistinct(y):
	y = y + 1
print(y)


def isDistinct(num):
	return num[0] != num[1] and num[0] != num[2] and (num[0] != num[3]) and (num[1] != num[2]) and (num[1] != num[3]) and (num[2] != num[3])
num = int(input())
for i in range(num + 1, 9015):
	new_num = str(i)
	if isDistinct(new_num):
		print(new_num)
		break


a = 0
x = int(input()) + 1

def judgement(p):
	for i in str(p):
		if str(p).count(i) > 1:
			global a
			a = 1
			return False
			break
	if a == 0:
		return True
while judgement(x) == False:
	x += 1
print(x)


def is_ok(value):
	i = 0
	while i < len(value):
		j = i + 1
		while j < len(value):
			if value[j] == value[i]:
				return False
			j += 1
		i += 1
	return True
nummer = str(int(str(input())) + 1)
while not is_ok(nummer):
	nummer = str(int(nummer) + 1)
print(nummer)


n = int(input())
for x in range(n + 1, 10000):
	temp = set(list(str(x)))
	if len(temp) == 4:
		print(x)
		break


a = input()
b = []
c = int(a)
while 1000 <= c <= 9000:
	a = int(a) + 1
	a = str(a)
	b = [a[0], a[1], a[2], a[3]]
	if int(b[0]) != int(b[1]) and int(b[0]) != int(b[2]) and (int(b[0]) != int(b[3])) and (int(b[1]) != int(b[2])) and (int(b[1]) != int(b[3])) and (int(b[2]) != int(b[3])):
		print(a)
		break


import sys
n = int(input())
for year in range(n + 1, 90000000):
	flag = True
	numbers_list = []
	for num in str(year):
		if num in numbers_list:
			flag = False
			break
		else:
			numbers_list.append(num)
	if flag:
		print(year)
		sys.exit()


def check(i):
	i = set(list(str(i)))
	if len(i) == 4:
		return 1
	return 0
a = []
for i in range(1000, 10000):
	if check(i):
		a.append(i)
import bisect
t = int(input())
if t in a:
	print(a[a.index(t) + 1])
else:
	i = bisect.bisect_right(a, t)
	print(a[i])


n = int(input())
n += 1
a = 0
while n <= 9012:
	s = str(n)
	if len(set(s)) == len(s):
		a = ''.join(s)
		break
	n += 1
print(a)


m = int(input())
while 1:
	m += 1
	n = str(m)
	l = len(n)
	flag = 1
	for i in range(l):
		for j in range(i + 1, l):
			if n[i] == n[j]:
				flag = 0
	if flag == 1:
		break
print(m)


def isDistinct(n):
	ls = [0] * 10
	while n != 0:
		x = n % 10
		if ls[x] > 0:
			return False
		else:
			ls[x] += 1
		n //= 10
	return True
n = int(input())
n += 1
while True:
	if isDistinct(n):
		print(n)
		break
	n += 1


year = int(input())
while True:
	year = year + 1
	y = list(str(year))
	Y = []
	for i in range(4):
		if y[i] not in Y:
			Y.append(y[i])
	if len(Y) == 4:
		print(year)
		quit()


n = int(input())
for i in range(n + 1, n + 1000):
	year_list = [j for j in str(i) if str(i).count(j) == 1]
	if len(year_list) == 4:
		print(i)
		break


y = int(input())
for y in range(y + 1, 1000000007):
	s = set(str(y))
	if len(s) == 4:
		print(y)
		break


import itertools

def beauty(year):
	combi = itertools.combinations(year, 2)
	for i in combi:
		if i[0] == i[1]:
			return False
	return True
year = input()
nexty = int(year) + 1
while beauty(str(nexty)) != True:
	nexty += 1
print(nexty)


n = int(input())
n += 1
while 1:
	ns = str(n)
	if len(ns) == len(set(ns)):
		print(ns)
		break
	else:
		n += 1


s = int(input())
while 1:
	l = {}
	s += 1
	p = str(s)
	p = list(p)
	l = set(p)
	if len(l) == len(p):
		print(s)
		break


n = int(input())
for i in range(1, 9000):
	a = int(str(n + i)[0])
	b = int(str(n + i)[1])
	c = int(str(n + i)[2])
	d = int(str(n + i)[3])
	if (a - b) * (a - c) * (a - d) * (b - c) * (b - d) * (c - d) != 0:
		print(n + i)
		break


def unbeatiful(n):
	num = []
	while n > 0:
		rem = n % 10
		n = int(n / 10)
		if rem in num:
			return False
		else:
			num.append(rem)
	else:
		return True
n = int(input())
i = 0
k = 1
while i < 4:
	n = n + 1
	bo = unbeatiful(n)
	if bo == True:
		break
print(n)


def isDistinct(x):
	mylist = []
	while x > 0:
		mylist.append(x % 10)
		x = x // 10
	mylist.sort()
	if mylist[0] == mylist[1] or mylist[1] == mylist[2] or mylist[2] == mylist[3]:
		return False
	else:
		return True
n = int(input())
for i in range(n + 1, 10000, 1):
	if isDistinct(i):
		print(i)
		break


n = int(input())

def is_unique(s):
	ans = {}
	for i in range(len(s)):
		if s[i] in ans:
			return False
		ans[s[i]] = 1
	return True
while True:
	n += 1
	a = is_unique(str(n))
	if a:
		break
print(n)


n = int(input())
(x, y, z, p) = (0, 0, 0, 0)
while 1:
	n = n + 1
	x = n % 10
	y = n // 10 % 10
	z = n // 100 % 10
	p = n // 1000
	if x != y and x != z and (x != p) and (y != z) and (y != p) and (z != p):
		print(str(p) + str(z) + str(y) + str(x))
		break


y = int(input())
o = y
ready = 0
while not ready:
	s = list(str(y))
	if s.count(s[0]) == 1 and s.count(s[1]) == 1 and (s.count(s[2]) == 1) and (s.count(s[3]) == 1) and (o != y):
		print(y)
		ready = 1
	else:
		y += 1


n = int(input())
k = True
while k:
	k = False
	n += 1
	s = str(n)
	for i in s:
		if s.find(i) != s.rfind(i):
			k = True
			break
print(n)


def distinct(Y):
	while True:
		Y = str(int(Y) + 1)
		if len(set(Y)) == 4:
			return Y
print(distinct(input()))


st = input()
num = int(st)
if 1000 <= num <= 9000:
	for i in range(num + 1, num + 200):
		if len(set(str(i))) == 4:
			print(i)
			break


year = int(input())
new = year + 1
while len(set([i for i in str(new)])) != 4:
	new += 1
print(new)


x = int(input())
cur = x + 1
while True:
	x = str(cur)
	x = list(x)
	if len(set(x)) == len(x):
		print(''.join(x))
		break
	cur += 1


n = int(input()) + 1
while True:
	li = list(str(n))
	for i in range(len(li)):
		on = True
		if li[i] in li[i + 1:]:
			n = n + 1
			on = False
			break
	if on:
		print(''.join(li))
		break


year = int(input())
for new_year in range(year + 1, 10000):
	if len(str(new_year)) == len(set(str(new_year))):
		print(new_year)
		break


import collections
n = input()
ans = int(n)
while True:
	ans += 1
	d = collections.Counter(str(ans))
	flag = 0
	for i in str(ans):
		if d[i] > 1:
			flag = 1
			break
	if flag == 0:
		print(ans)
		break


n = input()
n = str(int(n) + 1)
i = 0
while i != len(n):
	i = 0
	num = []
	for x in n:
		num.append(x)
	for a in range(len(n)):
		i += num.count(n[a])
	n = str(int(n) + 1)
print(int(n) - 1)


n = input()
n = int(n) + 1
n = str(n)
for i in range(10000):
	s1 = n.count(n[0])
	s2 = n.count(n[1])
	s3 = n.count(n[2])
	s4 = n.count(n[3])
	if s1 == s2 == s3 == s4 == 1:
		print(n)
		break
	else:
		n = int(n) + 1
		n = str(n)


a = input()
for x in range(int(a) + 1, 9999):
	x = str(x)
	if len(list(set([x[0], x[1], x[2], x[3]]))) == 4:
		print(x)
		break


n = int(input())
n += 1
while True:
	if len(set([n // 1000, n % 1000 // 100, n % 100 // 10, n % 10])) < 4:
		n += 1
	else:
		break
print(n)


n = int(input())
for i in range(n + 1, 9999):
	k = list(str(i))
	(a, b, c, d) = (k[0], k[1], k[2], k[3])
	if a in {b, c, d}:
		continue
	if b in {c, d}:
		continue
	if c == d:
		continue
	break
print(i)


def isBeautiful(year):
	numberSet = set()
	for i in year:
		if i in numberSet:
			return isBeautiful(str(int(year) + 1))
		else:
			numberSet.add(i)
	print(year)
import sys
year = int(input())
isBeautiful(str(year + 1))


a = input()
b = int(a) + 1
print()
while len(a) - len(set(str(b))) != 0:
	b += 1
print(b)


x = int(input())
while True:
	x = x + 1
	flag = False
	y = str(x)
	for i in range(4):
		for j in range(i + 1, 4):
			if y[i] == y[j]:
				flag = True
	if flag == False:
		break
print(x)


p = True
q = int(input())
while p:
	q += 1
	n = list(str(q))
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[2] != n[1]) and (n[3] != n[1]) and (n[2] != n[3]):
		print(q)
		p = False


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
for i in range(n + 1, 999999991):
	if len(set(str(i))) == 4:
		print(i)
		exit()


from collections import Counter
n = int(input())
while True:
	n += 1
	c = Counter(str(n))
	if not any((value > 1 for value in c.values())):
		print(n)
		break


n = int(input())
n += 1
a = n // 1000
b = n // 100 % 10
c = n % 100 // 10
d = n % 10
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	n += 1
	a = n // 1000
	b = n // 100 % 10
	c = n % 100 // 10
	d = n % 10
print(n)


year = int(input())
while 1:
	year += 1
	stryear = str(year)
	beautiful = 1
	for i in range(len(stryear) - 1):
		for j in range(i + 1, len(stryear)):
			if stryear[i] == stryear[j]:
				beautiful = 0
	if beautiful == 1:
		print(stryear)
		break


import sys
y = int(input()) + 1
li = [0] * 4
while True:
	i = y
	for j in range(4):
		li[j] = i % 10
		i //= 10
	if len(set(li)) == len(li):
		[print(i, end='') for i in li[::-1]]
		sys.exit()
	y += 1


n = int(input())

def DIS(m):
	m = sorted(list(str(m)))
	for i in range(len(m) - 1):
		if m[i] == m[i + 1]:
			return False
	return True
while True:
	n += 1
	if DIS(n):
		print(n)
		break


def alg_diff(n):
	tos = str(n)
	dic = {}
	for c in tos:
		if c in dic:
			return False
		else:
			dic[c] = 1
	return True
s = input()
n = int(s)
n += 1
while True:
	if alg_diff(n):
		print(str(n))
		break
	n += 1


y = str(int(input()) + 1)
done = False
while y[0] == y[1] or y[0] == y[2] or y[0] == y[3] or (y[1] == y[2]) or (y[1] == y[3]) or (y[2] == y[3]):
	y = str(int(y) + 1)
print(y)


x = int(input())
next = x + 1
while not len(str(next)) == len(set(str(next))):
	next += 1
print(next)


year = int(input())

def is_distinct(year):
	for y in str(year):
		if str(year).count(y) > 1:
			return False
	return True
year += 1
while not is_distinct(year):
	year += 1
print(year)


r = int(input())
r = r + 1
for j in range(r, 10000):
	i = str(j)
	w = list(i)
	if w[0] != w[1]:
		if w[0] != w[2]:
			if w[0] != w[3]:
				if w[1] != w[2]:
					if w[1] != w[3]:
						if w[2] != w[3]:
							print(i, '\n')
							break


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def getlistofstring():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
n = int(input())
while True:
	n += 1
	if len(set(str(n))) == 4:
		break
print(n)


a = int(input())

def year(num):
	b = {num % 10, num // 10 % 10, num // 100 % 10, num // 1000 % 10}
	return len(b)
x = 0
while x != 4:
	x = year(a + 1)
	if x == 4:
		print(a + 1)
	a = a + 1


s = int(input())
a = set()
while s < 9013:
	s += 1
	for x in str(s):
		a.add(x)
	if len(a) == 4:
		print(s)
		break
	a.clear()


def myfun(n):
	s = str(n)
	for i in s:
		if s.count(i) >= 2:
			return False
	return True
n = int(input())
for i in range(n + 1, 10 ** 5):
	if myfun(i):
		print(i)
		break


year = int(input())
while True:
	year += 1
	y = [int(i) for i in str(year)]
	x = 0
	for i in range(len(y) - 1):
		if y[i] not in y[i + 1:]:
			x += 1
	if x == 3:
		break
print(year)


y = int(input())
a = {}
while y < 9100:
	y += 1
	a = set(str(y))
	if len(a) == 4:
		print(y)
		break


n = int(input())
while 1:
	n += 1
	a = [0 for i in range(6)]
	n = str(n)
	a[0] = int(n[0]) ^ int(n[1])
	a[1] = int(n[0]) ^ int(n[2])
	a[2] = int(n[0]) ^ int(n[3])
	a[3] = int(n[1]) ^ int(n[2])
	a[4] = int(n[1]) ^ int(n[3])
	a[5] = int(n[2]) ^ int(n[3])
	f = 0
	n = int(n)
	for i in range(6):
		if a[i] == 0:
			f = 1
			break
	if f == 0:
		print(n)
		break


y = int(input()) + 1
sy = str(y)
while True:
	new_arr = ''
	for x in sy:
		if x not in new_arr:
			new_arr += x
	if len(new_arr) == len(sy):
		print(new_arr)
		break
	else:
		y += 1
		sy = str(y)


s = input()

def isDiff(s):
	a = [0] * 10
	for b in s:
		a[int(b)] += 1
	for i in a:
		if i > 1:
			return False
	return True
i = int(s) + 1
while True:
	if isDiff(str(i)):
		print(i)
		break
	i += 1


r = int(input())
while True:
	r += 1
	if len(str(r)) == len(set(str(r))):
		print(r)
		break


g = int(input())
g += 1
while len(set(str(g))) != 4:
	g += 1
print(g)


a = int(input())

def unique(s):
	l = []
	p = 2
	for i in range(4):
		if s[i] not in l:
			l.append(s[i])
			p = 1
		else:
			p = 0
			break
	if p == 1:
		return True
	else:
		return False
for i in range(a + 1, 9999):
	b = str(i)
	if unique(b) == True:
		print(i)
		break


n = int(input())
ans = 0
for i in range(n + 1, 9500):
	N = str(i)
	if N.count('0') > 1 or N.count('1') > 1 or N.count('2') > 1 or (N.count('3') > 1) or (N.count('4') > 1) or (N.count('5') > 1) or (N.count('6') > 1) or (N.count('7') > 1) or (N.count('8') > 1) or (N.count('9') > 1):
		continue
	else:
		ans = i
		break
print(ans)


s = int(input())
for i in range(8000):
	s += 1
	if len(set(str(s))) == len(str(s)):
		print(s)
		exit()


startYear = str(int(input()) + 1)
yearFound = False
output = 0
while yearFound == False:
	yearFound = True
	for i in range(10):
		if len([j for j in list(startYear) if j == str(i)]) > 1:
			yearFound = False
	if yearFound == True:
		output = startYear
	else:
		startYear = str(int(startYear) + 1)
print(output)


y = int(input())
for n in range(y + 1, 9013):
	n = str(n)
	for (i, k) in enumerate(n):
		if k in n[:i] + n[i + 1:]:
			res = False
			break
		res = True
	if res == True:
		print(n)
		break


a = int(input())
count = 0
a += 1
while count == 0:
	b = a
	u = b % 10
	b -= u
	d = b % 100
	b -= d
	d /= 10
	c = b % 1000
	b -= c
	c /= 100
	m = b % 10000
	m /= 1000
	if u != d and u != c and (u != m) and (d != c) and (d != m) and (c != m):
		count = 1
	else:
		a += 1
print(a)


y = int(input())
if y >= 1000 and y <= 9000:
	while True:
		y += 1
		s = str(y)
		if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[0]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[0]) and (s[2] != s[1]) and (s[2] != s[3]) and (s[3] != s[0]) and (s[3] != s[1]) and (s[3] != s[1]):
			print(y)
			break


a = input()
b = []
active = True
while active:
	a = str(int(a) + 1)
	for i in range(len(a)):
		if a[i] not in b:
			b.append(a[i])
	if len(b) == len(a):
		active = False
	else:
		b = []
print(a)


a = int(input())
mas = []
for i in range(a + 1, 15000, 1):
	r = str(i)
	r1 = r[0]
	r2 = r[1]
	r3 = r[2]
	r4 = r[3]
	if r1 != r2 and r1 != r3 and (r1 != r4) and (r2 != r3) and (r2 != r4) and (r3 != r4):
		mas.append(r)
		break
print(''.join(mas))


y = int(input())
y = y + 1
while y <= 9012:
	nums = {}
	sy = str(y)
	i = 0
	if sy[0] == sy[1] or sy[0] == sy[2] or sy[0] == sy[3] or (sy[1] == sy[2]) or (sy[1] == sy[3]) or (sy[2] == sy[3]):
		y = y + 1
	else:
		print(y)
		break


def hasDistinct(num):
	hasDup = {}
	for i in num:
		hasDup[i] = 1
	if len(hasDup) == 4:
		return True
	else:
		return False
s = int(input())
s = s + 1
found = False
while found == False:
	if hasDistinct(str(s)):
		found = True
	else:
		s = s + 1
print(s)


nn = int(input())
for i in range(nn + 1, nn * 1000):
	l = len(str(i))
	if len(set(str(i))) == l:
		print(i)
		break


cy = input()
cy = str(int(cy) + 1)
while cy[0] == cy[1] or cy[0] == cy[2] or cy[0] == cy[3] or (cy[1] == cy[2]) or (cy[1] == cy[3]) or (cy[2] == cy[3]):
	if cy[0] == cy[3] or cy[1] == cy[3] or cy[2] == cy[3]:
		cy = str(int(cy) + 1)
	if cy[0] == cy[2] or cy[1] == cy[2]:
		m = int(cy[3])
		cy = str(int(cy) + 10 - m)
	if cy[0] == cy[1]:
		m = int(cy[2]) * 10 + int(cy[3])
		cy = str(int(cy) + 100 - m)
print(cy)


y = int(input())
for i in range(y + 1, 9013):
	k = []
	j = str(i)
	k.extend(j)
	h = set(k)
	if len(k) == len(h):
		print(i)
		break


n = int(input())
c = [0] * 10
i = n + 1
while 1:
	x = i
	flag = 0
	c = [0] * 10
	while x:
		c[x % 10] += 1
		x = x // 10
	for j in c:
		if j > 1:
			flag = 1
			break
	if flag == 0:
		print(i)
		break
	i += 1


def check(a):
	return len(set(str(a))) == len(str(a))
a = int(input())
while True:
	a += 1
	if check(a):
		print(a)
		break


y = int(input())
for yi in range(y + 1, 10001):
	if len(set(str(yi))) == 4:
		print(yi)
		break


n = int(input()) + 1

def unique(n):
	s = str(n)
	return len(s) == len(set(s))
while not unique(n):
	n += 1
print(n)


s = int(input())
for i in range(s + 1, 9123):
	if i // 1000 != i // 100 % 10 and i // 1000 != i % 100 // 10 and (i // 1000 != i % 10) and (i // 100 % 10 != i % 100 // 10) and (i // 100 % 10 != i % 10) and (i % 100 // 10 != i % 10):
		print(i)
		break


n = int(input())
n = n + 1
while n < 9013:
	if len(set(map(int, str(n)))) == 4:
		print(n)
		break
	n += 1


num = int(input())
ctr = num + 1
marmota = True
while marmota:
	test = str(ctr)
	halp = []
	for n in range(0, 4):
		halp.append(test[n])
	if halp[0] == halp[1] or halp[0] == halp[2] or halp[0] == halp[3] or (halp[1] == halp[2]) or (halp[1] == halp[3]) or (halp[2] == halp[3]):
		ctr += 1
	else:
		print(ctr)
		marmota = False


import math
import re
a = int(input())
while True:
	a += 1
	if len(str(a)) == len({*str(a)}):
		print(a)
		break


def check(n):
	return len(set(list(str(n)))) == len(list(str(n)))
n = int(input())
i = n + 1
while 1:
	if check(i):
		print(i)
		break
	i += 1


y = int(input())
for i in range(y + 1, 10000):
	p = []
	q = 0
	for j in range(4):
		if str(i)[j] in p:
			q = 1
			break
		else:
			p.append(str(i)[j])
	if q == 0:
		print(i)
		break


year = int(input()) + 1

def beautiful(num):
	stringNum = str(num)
	for i in stringNum:
		if stringNum.count(i) == 1:
			Arg1 = True
		else:
			Arg1 = False
			break
	return Arg1
while year <= 10000:
	if beautiful(year) == True:
		print(year)
		break
	else:
		year += 1


n = int(input())
for i in range(n + 1, 11000):
	if len(set(str(i))) == len(str(str(i))):
		print(i)
		quit()


a = int(input())
a += 1
while 1 == 1:
	l = [int(a % 10), int(a % 100 / 10), int(a % 1000 / 100), int(a / 1000)]
	if l.count(int(a % 10)) == 1 and l.count(int(a % 100 / 10)) == 1 and (l.count(int(a % 1000 / 100)) == 1) and (l.count(int(a / 1000)) == 1):
		break
	else:
		a += 1
print(a)


x = int(input()) + 1
while x != 1 << 32:
	if len(set(str(x))) == 4:
		print(x)
		break
	x += 1


import math
from collections import defaultdict
from collections import Counter
import itertools
n = int(input())
while len(Counter(str(n + 1))) != 4:
	n = n + 1
print(n + 1)


year = int(input())
new_year = year + 1
counter = 0
found = 0
while not found:
	year_list = list(''.join(str(new_year)))
	for digit in year_list:
		counter += year_list.count(digit)
	if counter == 4:
		print(new_year)
		found = 1
		break
	else:
		counter = 0
		found = 0
		new_year += 1


n = int(input())
n = n + 1
k = True
while k:
	n = [int(i) for i in str(n)]
	c = set(n)
	if len(c) == len(n):
		print(int(''.join(map(str, n))))
		k = False
	else:
		n = int(''.join(map(str, n)))
		n += 1


s = input()
s = str(int(s) + 1)
while 1:
	lst = []
	for i in s:
		lst.append(i)
	if len(set(lst)) == 4:
		print(s)
		break
	s = str(int(s) + 1)


n = int(input())
for i in range(n + 1, 10 ** 5):
	c = str(i)
	if c[0] != c[1] and c[0] != c[2] and (c[0] != c[3]) and (c[1] != c[2]) and (c[1] != c[3]) and (c[2] != c[3]):
		print(i)
		break


n = int(input())
for i in range(n, 9014):
	n += 1
	n = str(n)
	if n.count(n[0]) == 1 and n.count(n[1]) == 1 and (n.count(n[2]) == 1) and (n.count(n[3]) == 1):
		print(n)
		break
	else:
		n = int(n)


s = []
for i in range(1, 10):
	for j in range(10):
		if j != i:
			for k in range(10):
				if k != i and k != j:
					for l in range(10):
						if l != i and l != j and (l != k):
							s += [i * 1000 + j * 100 + k * 10 + l]
n = int(input())
for i in s:
	if i <= n:
		continue
	else:
		print(i)
		break


n = int(input())
n = n + 1
while n < 11000:
	if str(n)[0] == str(n)[3] or str(n)[1] == str(n)[3] or str(n)[2] == str(n)[3]:
		n = n + 1
	elif str(n)[1] == str(n)[0] or str(n)[2] == str(n)[0] or str(n)[1] == str(n)[2]:
		n = n + 1
	else:
		break
print(n)


n = int(input())
n += 1
while len(set(str(n))) <= 3:
	n += 1
print(n)


year = int(input())
year += 1
while sum([str(year).count(y) for y in str(year)]) != 4:
	year += 1
print(year)


def is_distint_num(year):
	if len(set(str(year))) == 4:
		return True
	return False
year = int(input())
while True:
	year += 1
	if is_distint_num(year):
		print(year)
		exit()


import math
l = int(input()) + 1
r = 9000
if l > 8976:
	print('9012')
else:
	g = 0
	i = l
	q = l
	k = 1
	while q > 0:
		k += 1
		q = q // 10
	while i < r + 1:
		n = i
		b = []
		f = 1
		while n > 0:
			a = n % 10
			if a not in b:
				f += 1
				b.append(a)
			n = n // 10
		if k == f:
			c = len(b)
			t = 0
			for j in range(0, c):
				t = pow(10, j) * b[j] + t
			if g == 0 and t == i and (t < 9000):
				print(t)
				g = 1
				break
		elif l > 9000 or l == 9000:
			print('9012')
		i += 1


line = input()
year = int(line)
year += 1

def is_distinct(str_year):
	for i in range(len(str_year) - 1):
		if len([j for (j, letter) in enumerate(str_year) if letter == str_year[i]]) > 1:
			return False
	return True
while True:
	if is_distinct(str(year)):
		print(str(year))
		break
	else:
		year += 1


y = int(input()) + 1
(a, b, c, d) = str(y)
while True:
	(a, b, c, d) = str(y)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
	y += 1
print(y)


n = int(input())
a = n + 1
while True:
	used = []
	b = a
	a0 = b // 1000
	b = b % 1000
	a1 = b // 100
	b = b % 100
	a2 = b // 10
	b = b % 10
	a3 = b // 1
	used.append(a0)
	if a1 not in used:
		used.append(a1)
	if a2 not in used:
		used.append(a2)
	if a3 not in used:
		used.append(a3)
	if len(used) == 4:
		print(a)
		break
	else:
		a += 1


n = int(input())
while True:
	n += 1
	b = int(n / 1000)
	c = int(n / 100) % 10
	d = int(n / 10) % 10
	e = int(n % 10)
	if b != c and b != d and (b != e) and (c != d) and (c != e) and (d != e):
		break
print(n)


n = input()
num = int(n) + 1
n = str(num)
(a, b, c, d) = map(int, list(n))
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	num += 1
	n = str(num)
	(a, b, c, d) = map(int, list(n))
print(n)


def distict(x):
	c = 1
	for i in range(0, len(x)):
		for j in range(i + 1, len(x)):
			if x[i] == x[j]:
				c = 0
	return c
y1 = int(input())
while True:
	y1 += 1
	if distict(str(y1)):
		break
print(y1)


n = int(input())
while True:
	n += 1
	li = list(str(n))
	li.sort()
	valid = True
	for i in range(1, 4):
		if li[i - 1] == li[i]:
			valid = False
	if valid:
		print(n)
		quit()


a = int(input())
while 1:
	a -= -1
	arr = [0] * 10
	b = a
	while b > 0:
		arr[b % 10] -= -1
		b //= 10
	ch = 1
	for i in arr:
		if i > 1:
			ch = 0
			break
	if ch:
		break
print(a)


input_y = int(input())
flag = 0
while True:
	if flag:
		break
	input_y += 1
	lst = list(map(int, str(input_y)))
	flag = len(set(lst)) == len(lst)
print(input_y)


n = input()
a = list(n)
b = int(n)
for i in range(b + 1, pow(10, 5)):
	s = str(i)
	b = list(set(s))
	if len(b) == 4:
		print(i)
		break
	else:
		continue


n = int(input())
st = ''
if n == 5555:
	print(5601)
	exit(0)
l = [0, 0, 0, 0]
swap = bool(1)
i = n + 1
s = 0
while swap == bool(1):
	s = 0
	l[0] = (i - i % 1000) / 1000
	l[1] = (i - 1000 - i % 100) / 100
	if l[1] >= 10:
		l[1] = (i - 1000 - i % 100) / 100 - (i - 1000 - i % 100) / 100 // 10 * 10
	l[2] = (i % 100 - i % 10) / 10
	l[3] = i % 10
	if l[0] == l[1] or l[0] == l[2] or l[0] == l[3] or (l[1] == l[2]) or (l[1] == l[3]) or (l[2] == l[3]):
		s += 1
	if s == 0:
		swap = bool(0)
	i += 1
for j in range(0, 4):
	st += str(int(l[j]))
print(st)


year = int(input())
while True:
	year += 1
	if len(set([ch for ch in str(year)])) == 4:
		print(year)
		break


import sys
user = int(input())
unique = 0
while True:
	user += 1
	unique = 0
	for j in range(0, 10):
		if str(j) in str(user):
			unique += 1
	if unique == 4:
		break
print(user)


def check(n):
	s = str(n)
	a = []
	for b in s:
		a.append(b)
	d = set(a)
	if len(d) == 4:
		return True
	else:
		return False
year = int(input())
num = 9999 - year
for i in range(1, num + 1):
	if check(year + i):
		print(year + i)
		break
	else:
		continue


n = int(input())
while n >= 1000 & n <= 9000:
	n += 1
	(a, d1) = divmod(n, 10)
	(a, d2) = divmod(a, 10)
	(a, d3) = divmod(a, 10)
	(a, d4) = divmod(a, 10)
	if (d1 != d2) & (d1 != d3) & (d1 != d4) & (d2 != d3) & (d2 != d4) & (d3 != d4):
		print(n)
		break


import math
year = list(input())
year_val = ''
year_val = int(year_val.join(year)) + 1
while True:
	flag_br = 0
	year_val_new = list(str(year_val))
	for i in range(len(year_val_new) - 1):
		for j in range(i + 1, len(year_val_new)):
			if year_val_new[i] == year_val_new[j]:
				flag_br = 1
				break
	if flag_br == 1:
		year_val += 1
	else:
		print(year_val)
		break


x = input()
while 1:
	y = int(x)
	y += 1
	x = str(y)
	i = set(x)
	if len(i) == len(x):
		print(y)
		break


n = int(input())
sw = 0
while sw == 0:
	n += 1
	temp = str(n)
	for i in range(0, 5):
		if temp[0] not in (temp[1], temp[2], temp[3]) and temp[1] not in (temp[2], temp[3]) and (temp[2] not in temp[3]):
			sw = temp
print(sw)


n = input()
flag = False
while flag == False:
	if int(n) != 10000:
		n = int(n) + 1
	l = [term for term in str(n)]
	f = len(set(l))
	if f == 4:
		flag = True
print(n)


year = int(input()) + 1

def unique_finder(num):
	num_arr = list(num)
	for i in range(0, len(num_arr)):
		for j in range(0, len(num_arr)):
			if j == i:
				continue
			if num_arr[i] == num_arr[j]:
				return False
	return True
while True:
	if unique_finder(str(year)):
		print(year)
		break
	else:
		year = year + 1


y = int(input())
for w in range(y + 1, 10000):
	for x in str(y + 1):
		if str(y + 1).count(x) > 1:
			y = y + 1
		else:
			year = y + 1
print(year)


year = int(input())
test = [1, 1, 1, 1]
while True:
	dic = {}
	year += 1
	l = list(str(year))
	for i in range(0, len(l)):
		l[i] = int(l[i])
	for i in l:
		dic[i] = dic.get(i, 0) + 1
	if list(dic.values()) == test:
		break
for i in l:
	print(i, end='')


n = int(input())
for k in range(n + 1, 9013):
	l = set(str(k))
	if len(l) == 4:
		print(k)
		break


s = str(input())
year = int(s)
digits = [s[0], s[1], s[2], s[3]]
while True:
	year += 1
	syear = str(year)
	digits[0] = syear[0]
	digits[1] = syear[1]
	digits[2] = syear[2]
	digits[3] = syear[3]
	if digits[0] != digits[1] and digits[0] != digits[2] and (digits[0] != digits[3]) and (digits[1] != digits[2]) and (digits[1] != digits[3]) and (digits[2] != digits[3]):
		print(year)
		break


y = int(input())
for i in range(1, 9000):
	z = str(y + i)
	if z[0] != z[1] and z[0] != z[2] and (z[0] != z[3]) and (z[1] != z[2]) and (z[1] != z[3]) and (z[2] != z[3]):
		print(z)
		break


def find(str):
	l1 = len(str)
	se = set(str)
	l2 = len(se)
	if l1 == l2:
		return 1
	else:
		return 0
s = input()
num = int(s)
for i in range(num + 1, 2147483647):
	st = str(i)
	if find(st):
		print(i)
		break


def find():
	f = int(input())
	while True:
		f += 1
		g = str(f)
		check = 0
		for i in range(0, 4):
			for j in range(0, 4):
				if j == i:
					continue
				if g[j] == g[i]:
					check = 1
					break
			if check == 1:
				break
		if check == 0:
			print(f)
			return
find()


year = input()
allyear = [i for i in range(int(year) + 1, 10001)]
for i in allyear:
	if len(set(str(i))) == 4:
		print(i)
		break


n = input()
flag = 0
n = int(n) + 1
n = str(n)
while flag != 1:
	if n[0] == n[1] or n[0] == n[2] or n[0] == n[3] or (n[1] == n[2]) or (n[1] == n[3]) or (n[2] == n[3]):
		n = int(n) + 1
		n = str(n)
	else:
		flag = 1
print(n)


year = int(input()) + 1
flag = True
while flag:
	string = list(str(year))
	if len(set(string)) == len(string):
		print(year)
		flag = False
	else:
		year += 1


i = str(int(input()) + 1)
while len(i) != len(set(i)):
	i = str(int(i) + 1)
print(i)


a = int(input())
while True:
	a += 1
	if len(set(str(a))) == len(str(a)):
		break
	else:
		continue
print(a)


def is_distinct(n):
	n_list = list(str(n))
	n_set = set(n_list)
	return len(n_set) == len(n_list)
n = int(input())
n += 1
while not is_distinct(n):
	n += 1
print(n)


m = input()
n = int(m)
if n < 1000 or n > 9000:
	exit()
m = list(str(int(m) + 1))
str1 = ''
while True:
	if m[0] == m[1] or m[0] == m[2] or m[0] == m[3] or (m[1] == m[2]) or (m[1] == m[3]) or (m[2] == m[3]):
		n += 1
		m = list(str(n))
	else:
		print(str1.join(m))
		break


t = int(input())
while True:
	t += 1
	if len(set(list(map(int, [x for x in str(t)])))) == 4:
		print(t)
		break


a = int(input()) + 1
for i in range(a, 10000):
	b = i % 10
	c = i // 10
	d = c % 10
	c //= 10
	e = c % 10
	c //= 10
	c = [b, c, d, e]
	if len(set(c)) == 4:
		print(i)
		break


n = int(input())
for x in range(n + 1, 10000):
	list1 = [y for y in str(x)]
	if len(set(list1)) == 4:
		print(x)
		break


x = input()
w = 0
while True:
	x = int(x)
	x = x + 1
	for i in range(0, 4):
		x = str(x)
		z = 0
		z = x.count(x[i])
		if z > 1:
			w = 1
			break
		else:
			w = 0
	if w == 1:
		continue
	else:
		break
print(x)


def isDigitsDif(n):
	digits = []
	while n > 0:
		digit = n % 10
		if digit in digits:
			return False
		else:
			digits.append(digit)
			n = n // 10
	return True
year = int(input())
nice_year = year + 1
while not isDigitsDif(nice_year):
	nice_year += 1
print(nice_year)


y = int(input())
i = y + 1
while i > 0:
	s = str(i)
	l = []
	flag = 0
	for each in s:
		l.append(each)
	for each in l:
		if s.count(each) > 1:
			flag = 0
			break
		else:
			flag = 1
	if flag == 1:
		break
	else:
		i += 1
print(i)


a = int(input())
b = a
flag = True
while flag:
	b += 1
	if len(str(b)) == len(set(str(b))):
		flag = False
		print(b)


y = int(input())
for i in range(y + 1, 10000):
	i = str(i)
	if i.count(i[0]) == 1 and i.count(i[1]) == 1 and (i.count(i[2]) == 1):
		print(i)
		break


def judge_sample(year):
	l = len(year)
	for i in range(l):
		for j in range(i + 1, l):
			if year[i] == year[j]:
				return True
	return False
year = int(input())
year += 1
while judge_sample(str(year)):
	year += 1
print(year)


def is_distinct(year):
	year = str(year)
	result = ''
	for i in year:
		if i not in result:
			result += i
	return len(result) == len(year)
n = int(input()) + 1
while is_distinct(n) != True:
	n += 1
else:
	print(n)


def DigitosDiferentes(Anio):
	A = Anio // 1000
	B = Anio % 1000 // 100
	C = Anio % 100 // 10
	D = Anio % 10
	L = []
	L.append(A)
	L.append(B)
	L.append(C)
	L.append(D)
	L.sort()
	return int(L[0]) != int(L[1]) != int(L[2]) != int(L[3])

def SiguienteAnioDiferente(Anio):
	i = Anio
	while i > 0:
		i += 1
		if DigitosDiferentes(i):
			break
	return i
Anio = input()
A = int(Anio)
print(SiguienteAnioDiferente(A))


def isUniqueChars(st):
	if len(st) > 4:
		return False
	char_set = [False] * 128
	for i in range(0, len(st)):
		val = ord(st[i])
		if char_set[val]:
			return False
		char_set[val] = True
	return True
y = int(input())
y += 1
m = str(y)
while not isUniqueChars(m):
	y += 1
	m = str(y)
print(y)


year = int(input())
k = 0
test = year
while k == 0:
	test = test + 1
	test_set = set(str(test))
	if len(test_set) == 4:
		print(test)
		k = 1
		break


n = input()
p = int(n)
z = list(map(int, n))
while True:
	p += 1
	z = [i for i in str(p)]
	if len(z) == len(set(z)):
		print(p)
		break


import math

def isLucky(n):
	ar = [0] * 10
	while n > 0:
		digit = math.floor(n % 10)
		if ar[digit]:
			return 0
		ar[digit] = 1
		n = n // 10
	return 1
n = int(input())
n += 1
while True:
	if isLucky(n):
		print(n)
		break
	n += 1


from collections import Counter
year = int(input())
isBeautifulYear = False
while not isBeautifulYear:
	year += 1
	strYear = str(year)
	lengthOfYear = Counter(strYear)
	isBeautifulYear = True
	for (k, v) in lengthOfYear.items():
		if v > 1:
			isBeautifulYear = False
print(year)


n = int(input())
while n <= 9012:
	n += 1
	ss = set(str(n))
	if len(ss) == 4:
		print(n)
		break


year = int(input())
notFound = True
while notFound:
	year += 1
	year = str(year)
	if year.count(year[0]) == 1 and year.count(year[1]) == 1 and (year.count(year[2]) == 1):
		print(year)
		notFound = False
	else:
		year = int(year)


year = int(input())
a1 = year % 10
a2 = year % 100 // 10
a3 = year % 1000 // 100
a4 = year // 1000
condition = True
while condition:
	year += 1
	a1 = year % 10
	a2 = year % 100 // 10
	a3 = year % 1000 // 100
	a4 = year // 1000
	if a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a3 != a4) and (a2 != a4):
		condition = False
print(a4, a3, a2, a1, sep='')


n = int(input())
n = n + 1
while n <= 9013:
	m = n
	a = n % 10
	m = m // 10
	b = m % 10
	m = m // 10
	c = m % 10
	d = m // 10
	if a == b or a == c or a == d:
		n = n + 1
	elif c == b or d == c or b == d:
		n = n + 1
	else:
		print(n)
		break


inpt = int(input())
n = 0
while n != 1:
	inpt += 1
	x = str(inpt)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[2]) and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		n += 1
print(inpt)


y = input()
y = int(y) + 1
madhu = 1
while madhu:
	flag = 0
	x = 0
	b = [int(x) for x in str(y)]
	for i in range(0, 4):
		for i1 in range(0, 4):
			if i != i1:
				if b[i] == b[i1]:
					flag = 1
	if not flag:
		madhu = 0
	else:
		y = int(y) + 1
print(y)


n = int(input())

def sumr(n):
	n = str(n)
	a = 0
	for i in n:
		a += int(i)
	if len(set(n)) == 4:
		return True
	return False
for i in range(n + 1, 9013):
	a = sumr(i)
	if a == True:
		break
print(i)


def ras(y):
	y = y + 1
	while True:
		y = str(y)
		for i in range(len(y)):
			x = y[i + 1:]
			if y[i] in x:
				break
			elif i == len(y) - 1:
				return y
		y = int(y)
		y = y + 1
	return y
y = int(input())
r = ras(y)
print(r)


n = int(input())
n += 1
while True:
	y = str(n)
	hs = set()
	for i in y:
		hs.add(i)
	if len(hs) == len(y):
		print(n)
		break
	else:
		n += 1


n = int(input())
while 1:
	n += 1
	x = str(n)
	l = [str(x[0]), str(x[1]), str(x[2]), str(x[3])]
	if len(set(l)) == 4:
		print(n)
		break


y = input()
y = str(int(y) + 1)
while True:
	b = True
	for x in y:
		if y.count(x) > 1:
			b = False
			break
	if not b:
		y = str(int(y) + 1)
	else:
		print(y)
		break


import sys, os, io, time
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def distinct(n):
	m = n
	dic = {}
	while m > 0:
		x = m % 10
		m = m // 10
		if x in dic:
			return False
		else:
			dic[x] = 1
	return True

def main():
	n = int(input())
	i = n + 1
	while True:
		if distinct(i):
			print(i)
			break
		i += 1
main()


a = int(input())
for i in range(a + 1, 10000):
	i1 = str(i)
	if len(set(i1)) == 4:
		print(i1)
		break


start = int(input(''))

def get_digits(x):
	result = []
	while x > 0:
		result.append(x % 10)
		x = int(x / 10)
	return result

def is_different(x):
	for i in range(len(x)):
		for j in range(i + 1, len(x)):
			if x[i] == x[j]:
				return False
	return True
start += 1
while not is_different(get_digits(start)):
	start += 1
print(str(start))


n = int(input())
found = False
while not found:
	n += 1
	z = set([])
	for i in str(n):
		z.add(i)
	if len(z) == len(str(n)):
		found = True
print(n)


y = int(input())

def dup(a):
	l = []
	for i in a:
		if i not in l:
			l.append(i)
	return l
while True:
	y += 1
	a = list(str(y))
	if dup(a) == a:
		print(y)
		break


year = int(input())
distinct = 0
while True:
	year += 1
	distinct = 0
	for digit in str(year):
		if str(year).count(digit) > 1:
			break
		else:
			distinct += 1
	if distinct == 4:
		break
print(year)


y = int(input())
while len(set(str(y))) <= len(str(y)):
	if len(str(y)) == len(set(str(y))):
		y += 1
		if len(str(y)) == len(set(str(y))):
			print(y)
			break
		else:
			continue
	else:
		y += 1
		if len(set(str(y))) == len(str(y)):
			print(y)
			break


x = input()
z = int(x)
y = list(x)
while 1:
	z += 1
	k = str(z)
	m = list(k)
	n = set(m)
	if len(m) == len(n):
		print(z)
		break


b = int(input())
while True:
	b += 1
	c = str(b)
	if len(set(c)) == len(c):
		print(b)
		break


n = int(input())
for i in range(n + 1, 10000):
	S = str(i)
	M = {x for x in S}
	if len(M) == 4:
		print(i)
		break


def bf(s):
	l = list(s)
	l = l + ['a']
	l = sorted(l)
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			return 1
ss = input()
i = 1
while 1 == 1:
	x = str(int(ss) + i)
	if bf(x) != 1:
		break
	i = i + 1
print(x)


n = int(input())

def checkNumbers(x):
	n1 = x // 1000
	n2 = x // 100 % 10
	n3 = x // 10 % 10
	n4 = x % 10
	if n1 != n2 and n1 != n3 and (n1 != n4) and (n2 != n3) and (n2 != n4) and (n3 != n4):
		return True
	return False
i = n + 1
while True:
	if checkNumbers(i):
		print(i)
		break
	i += 1


year = int(input())
flag = 1
year += 1
while flag == 1:
	flag = 0
	count = [0] * 10
	temp = year
	while temp > 0:
		count[temp % 10] += 1
		temp //= 10
	for i in range(10):
		if count[i] > 1:
			flag = 1
			year += 1
			break
print(year)


x = list(map(int, input()))
i = 1
t = 0
while i:
	if x[3] <= 10:
		x[3] = x[3] + 1
		if x[3] == 10:
			x[3] = 0
			x[2] += 1
	if x[2] == 10:
		x[2] = 0
		x[1] = x[1] + 1
	if x[1] == 10:
		x[1] = 0
		x[0] += 1
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		i = 0
x = map(str, x)
print(''.join(x))


def fun(n):
	li = [0 for i in range(10)]
	while n > 0:
		x = n % 10
		li[x] += 1
		if li[x] == 2:
			return False
		n = n // 10
	return True

def main():
	n = int(input())
	while True:
		n = n + 1
		if fun(n):
			print(n)
			break
main()


i = int(input())
y = list()
x = list()
f = 1
while y != x or f == 1:
	f = 0
	i += 1
	a = str(i)
	x = list()
	y = list()
	for j in range(0, len(a)):
		x.append(a[j])
	y = sorted(set(x))
	x = sorted(x)
	if y == x:
		print(i)
		break


def has_unique(inputNb: int) -> bool:
	inputNb = str(inputNb)
	return sorted(list(set(inputNb))) == sorted(list(inputNb))
nb = int(input())
re = nb + 1
while not has_unique(re):
	re += 1
print(re)


a = int(input())
a += 1
(b, c, d, e) = (str(a)[0], str(a)[1], str(a)[2], str(a)[3])
while b == c or c == d or d == e or (b == d) or (b == e) or (c == e):
	a += 1
	(b, c, d, e) = (str(a)[0], str(a)[1], str(a)[2], str(a)[3])
print(a)


y = int(input())
for i in range(y + 1, 9000001):
	if len(set(' '.join(str(i)).split())) == 4:
		print(i)
		exit()


def differ_numbers(number):
	number = str(number)
	lista = []
	for char in number:
		if char in lista:
			return False
		else:
			lista.append(char)
	return True
number = int(input())
number += 1
while not differ_numbers(number):
	number += 1
print(number)


x = int(input())
i = 1
while i > 0:
	x += 1
	y = str(x)
	z = {a for a in y}
	if len(z) == 4:
		i = 0
print(x)


n = int(input())
for k in range(n + 1, 12346):
	if len(str(k)) == len(set(str(k))):
		print(k)
		break


def check(k):
	s = str(k)
	l = []
	for x in s:
		if x not in l:
			l.append(x)
	if len(l) < len(s):
		return True
	else:
		return False
num = int(input()) + 1
while check(num):
	num += 1
print(num)


y = int(input())
y1 = y + 1
while True:
	s = str(y1)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(y1)
		break
	y1 += 1


y = input()
y = int(y)
y = y + 1
while y <= 9999:
	ind = 0
	s = str(y)
	l = list(s)
	for i in range(len(l) - 1):
		for j in range(i + 1, len(l)):
			if l[i] == l[j]:
				ind = 1
			else:
				pass
	if ind == 0:
		print(y)
		break
	y = y + 1


n = int(input())
count = 0
for i in range(n + 1, 9015):
	s = str(i)
	a = ''
	for z in range(4):
		if a.find(s[z]) == -1:
			a += s[z]
	if len(a) == 4:
		count = i
		break
print(count)


def main():
	y = int(input())
	for i in range(y + 1, 10000):
		a = i % 10
		b = i // 10 % 10
		c = i // 100 % 10
		d = i // 1000
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			print(i)
			return
main()


y = int(input())

def temp(n):
	ans = 0
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		ans = n
	return ans
for x in range(y + 1, 9013):
	if temp(x) > 0:
		print(temp(x))
		break


n = int(input())
for i in range(n + 1, n + 10000):
	a = str(i)
	flag = True
	for j in range(len(a)):
		for e in range(j + 1, len(a)):
			if a[j] == a[e]:
				flag = False
				break
		if flag == False:
			break
	if flag == True:
		print(i)
		break


y = int(input())
n = y
checked = []
flag = 0
while True:
	n += 1
	for i in str(n):
		if str(i) in checked:
			flag = 1
		checked.append(str(i))
	checked = []
	if flag == 0:
		break
	flag = 0
print(n)


n = int(input())
le = len(str(n))
for i in range(1000, 10001):
	if i > n:
		s = set()
		st = str(i)
		s = set(st)
		if len(s) == le:
			print(i)
			break


import sys
year = int(input())
for i in range(year + 1, sys.maxsize):
	if len(set(str(i))) == len(str(i)):
		print(i)
		break


def getdigits(n):
	x = []
	while n > 0:
		x.append(n % 10)
		n = n // 10
	return x
k = int(input())
while k > 0:
	k += 1
	y = getdigits(k)
	x = set(y)
	if len(x) == len(y):
		print(k)
		quit()


n = int(input())
for i in range(n + 1, 9013):
	a = int(i % 10)
	b = int(i / 10 % 10)
	c = int(i / 100 % 10)
	d = int(i / 1000 % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		res = i
		break
print(res)


n = int(input())
for i in range(1, 9000):
	p = ''
	q = ''
	c = 0
	p = str(n + i)
	for j in range(0, len(p)):
		q = p[j + 1:] + p[:j]
		if p[j] in q:
			break
		else:
			c += 1
	if c == len(p):
		print(p)
		break


x = input('')
y = int(x) + 1
x = str(y)
for c in range(10000):
	if x[0] == x[1] or x[0] == x[2] or x[0] == x[3]:
		y += 1
		x = str(y)
	elif x[1] == x[2] or x[1] == x[3]:
		y += 1
		x = str(y)
	elif x[2] == x[3]:
		y += 1
		x = str(y)
	else:
		print(x)
		break


def uniques(numbers):
	for number in numbers:
		str_number = str(number)
		if len(set(str_number)) == len(str_number):
			yield number
n = int(input())
for i in uniques(range(1000, 9050)):
	if i > n:
		print(i)
		break


n = int(input())

def dis(n):
	x = str(n)
	z = set(x)
	if len(z) == len(x):
		return True
	return False
c = False
while c != True:
	n += 1
	if dis(n):
		c = True
print(n)


n = int(input())
while True:
	n += 1
	arr = [i for i in str(n)]
	if len(set(arr)) >= 4:
		print(n)
		break


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input()) + 1
	while True:
		if len(str(n)) == len(set(str(n))):
			print(n)
			return
		n += 1
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())

def krasiviyGod(n):
	for i in range(n + 1, 10000):
		if len(set(str(i))) == 4:
			return i
a = krasiviyGod(n)
print(a)


n = int(input())
n = n + 1
str(n)
k = []

def tekrar(x):
	c = []
	x = str(x)
	for i in range(len(x)):
		a = x.count(x[i])
		c.append(a)
	for i in range(c.count(0)):
		c.remove(0)
	for i in range(c.count(1)):
		c.remove(1)
	if len(c) == 0:
		return True
	else:
		return False
if tekrar(n) == True:
	print(n)
elif tekrar(n) == False:
	while tekrar(n) == False:
		int(n)
		n += 1
		str(n)
		k.append(n)
	print(k[-1])


x = int(input())
for i in range(x + 1, 9030):
	y = str(i)
	un = []
	for char in y:
		if char in un:
			break
		else:
			un.append(char)
	if len(un) == len(y):
		print(i)
		break


l = int(input()) + 1
while len(set(str(l))) < 4:
	l += 1
print(l)


n = int(input())
i = 1
while len(set(str(n + 1))) != 4:
	n += 1
else:
	print(n + 1)


year = int(input())
flag = False
for i in range(year + 1, 9013):
	string_year = str(i)
	for j in range(4):
		if string_year.count(string_year[j]) > 1:
			break
		if j == 3:
			flag = True
	if flag == 1:
		print(i)
		break


y = int(input())
t = []
for i in range(y + 1, 9013):
	q = list(str(i))
	k = [int(bool(q.count(q[p]) == 1)) for p in range(4)]
	s = 0
	for r in k:
		s += r
		if s == 4:
			t += [i]
print(t[0])


n = input()
(r, l) = (int(n) + 1, len(n))
while 1:
	w = len(set(str(r)))
	if l == w:
		print(r)
		break
	else:
		r += 1


n = int(input())
N = n + 1
while True:
	S = set(list(str(N)))
	if len(S) == 4:
		print(N)
		break
	N += 1


a = str(int(input()) + 1)
while True:
	if list(sorted(set(a))) == list(sorted(a)):
		print(a)
		break
	else:
		a = str(int(a) + 1)
		continue


def check(s):
	s = str(s)
	if len(s) == len(set(s)):
		return True
	else:
		return False
n = int(input())
n += 1
while not check(n):
	n += 1
print(n)


def distinct(year):
	distinct_count = set()
	c = 0
	while year:
		last_num = year % 10
		year = year // 10
		c = c + 1
		distinct_count.add(last_num)
	if len(distinct_count) == c:
		return True
	else:
		return False
year = int(input())
while True:
	year = year + 1
	if distinct(year) is True:
		break
	else:
		continue
print(year)


n = int(input())
while 1:
	n = n + 1
	s = str(n)
	l = set()
	for j in s:
		l.add(j)
	if len(s) == len(l):
		print(n)
		break


y = int(input())
ny = y + 1
while list(str(ny)) != list(dict.fromkeys(list(str(ny)))):
	ny += 1
print(ny)


def dis(f):
	L = ['!']
	for i in range(len(f)):
		for j in L:
			if f[i] == j:
				return True
		L.append(f[i])
	return False
i = int(input()) + 1
while True:
	if dis(str(i)) == True:
		i += 1
	else:
		break
print(i)


year = input()
res = 0
while res >= 0:
	year = str(int(year) + 1)
	if len(set(year)) == 4:
		print(year)
		break


inp = input()
inp = int(inp)
l = []
e = ''
while True:
	inp += 1
	inp = str(inp)
	for num in inp:
		if num not in l:
			l.append(num)
	if len(l) == 4:
		for letter in l:
			e += letter
		print(e)
		break
	else:
		l = []
		e = ''
		inp = int(inp)


y = int(input())
flag = bool(0)
while flag != 1:
	y += 1
	a = list(map(int, str(y)))
	if a[0] == a[1] or a[0] == a[2] or a[0] == a[3] or (a[1] == a[2]) or (a[1] == a[3]) or (a[2] == a[3]):
		flag = 0
	else:
		flag = 1
		print(str(a[0]) + str(a[1]) + str(a[2]) + str(a[3]))


def checkifUnique(year):
	temp = str(year)
	for i in temp:
		if temp.count(i) != 1:
			return 0
	return 1
year = int(input())
year = year + 1
while year <= 10000:
	if checkifUnique(year):
		print(year)
		break
	year = year + 1


s = input()
sz = len(s)
s = str(int(s) + 1)
while len(set(str(int(s)))) != sz:
	t = int(s) + 1
	s = str(t)
print(int(s))


n = int(input())
new_n = n + 1
count = 0
while True:
	year = str(new_n)
	count = 0
	l = []
	accepted = True
	while count < len(year):
		i = year[count]
		if i not in l:
			l = l + [i]
		else:
			accepted = False
		count += 1
	if not accepted:
		new_n += 1
	else:
		print(new_n)
		break


a = int(input()) + 1
a = list(str(a))
for i in range(8000):
	k = 0
	if '0' in a:
		k += 1
	if '1' in a:
		k += 1
	if '2' in a:
		k += 1
	if '3' in a:
		k += 1
	if '4' in a:
		k += 1
	if '5' in a:
		k += 1
	if '6' in a:
		k += 1
	if '7' in a:
		k += 1
	if '8' in a:
		k += 1
	if '9' in a:
		k += 1
	if k == 4:
		print(''.join(a))
		break
	else:
		a = int(''.join(a)) + 1
		a = list(str(a))


n = int(input()) + 1

def is_diff(w):
	for i in w:
		if w.count(i) > 1:
			return 0
	return 1
while is_diff(str(n)) == 0:
	n += 1
print(n)


year = int(input())
year += 1
year = str(year)
while year[0] in year[1:] or year[1] in year[2:] or year[2] == year[3]:
	year = int(year)
	year += 1
	year = str(year)
print(year)


def isdist(s):
	s = str(s)
	for i in range(len(s)):
		if s[i] in list(s[i + 1:]):
			return 0
	return 1
n = int(input())
n += 1
while 1:
	if isdist(n):
		print(n)
		break
	n += 1


n = int(input())
v = n
while 1:
	v = v + 1
	m = str(v)
	l = []
	for i in range(len(m)):
		l.append(int(m[i]))
	if len(l) == len(set(l)):
		print(int(m))
		break


def Distinct(n):
	n = set(str(n))
	if len(n) == 4:
		return True
	else:
		return False
cur = int(input())
cur += 1
while not Distinct(cur):
	cur += 1
print(cur)


def get_values():
	string = input()
	num = int(string)
	result = beauty(num)
	return print(result)

def beauty(m):
	dis = ''
	m = int(m) + 1
	for i in str(m):
		if i not in dis:
			dis += i
	if len(dis) != 4:
		dis = beauty(m)
	return int(dis)
get_values()


t = int(input())
i = t + 1
while True:
	if len(set(list(str(i)))) == 4:
		print(i)
		break
	i += 1


n = int(input())
for i in range(1, 1000):
	m = 0
	j = n + i
	s = list(map(int, str(j)))
	s = set(s)
	m = len(s)
	if len(s) == 4:
		print(j)
		break


y = int(input())
y += 1

def check(i):
	return len(set(str(i))) == 4
while not check(y):
	y += 1
print(y)


import sys

def year():
	listyear = []
	year = input().split()
	k = True
	for i in range(len(year[0])):
		listyear.append(int(year[0][i]))
	listyear.reverse()
	return listyear

def nextyear(listyear):
	if listyear[0] == 9:
		listyear[0] = 0
		if listyear[1] == 9:
			listyear[1] = 0
			if listyear[2] == 9:
				listyear[2] = 0
				if listyear[3] == 9:
					listyear[3] = 0
				else:
					listyear[3] += 1
			else:
				listyear[2] += 1
		else:
			listyear[1] += 1
	else:
		listyear[0] += 1
	return listyear

def rightyear(listyear):
	nextyear(listyear)
	while len(set(listyear)) != 4:
		listyear = nextyear(listyear)
	listyear.reverse()
	for i in listyear:
		print(i, end='')
rightyear(year())


cp = int(input())
cp = cp + 1
ctr = 1
while ctr:
	if len(set(str(cp))) == 4:
		print(cp)
		ctr = 0
		break
	cp = cp + 1


n = int(input())
while True:
	x = [i for i in str(n + 1)]
	if len(x) == len(set(x)):
		print(n + 1)
		break
	n += 1


n = int(input())
n = n + 1
f = str(n)
x = len(f)
y = set(f)
while x != len(y):
	n = int(f)
	n = n + 1
	f = str(n)
	x = len(f)
	y = set(f)
print(f)


inp = input()
n = int(inp)
k = n + 1
points = 0
while points < 4:
	points = 0
	temp = k
	a = []
	for i in range(1, 5):
		r = temp % 10
		if not r in a:
			a.append(r)
			points += 1
			temp -= r
			temp /= 10
	if points == 4:
		print(k)
		break
	else:
		k += 1


n = int(input())
year = n + 1
while str(year)[0] == str(year)[1] or str(year)[0] == str(year)[2] or str(year)[0] == str(year)[3] or (str(year)[1] == str(year)[2]) or (str(year)[1] == str(year)[3]) or (str(year)[2] == str(year)[3]):
	year += 1
print(year)


found = False
n = int(input())
n += 1
while not found:
	if len(set(list(str(n)))) == 4:
		found = True
		print(n)
	else:
		n += 1


a = int(input()) + 1
while True:
	b = str(a)
	if b.count(b[0]) == b.count(b[1]) == b.count(b[2]) == 1:
		print(b)
		exit()
	a += 1


mass = []
count = 1
year = int(input())
while count == 1:
	year += 1
	mass = []
	mass.append(year // 1000)
	mass.append(year // 100 % 10)
	mass.append(year % 100 // 10)
	mass.append(year % 10)
	for i in range(len(mass)):
		for j in range(len(mass)):
			if mass[i] == mass[j] and i != j:
				count = 1
				break
			else:
				count = 0
		if count == 1:
			break
print(year)


y = int(input())
yay = 0

def valid(x):
	diff = True
	for j in range(0, 4):
		for k in range(0, 4):
			if j == k:
				diff = diff and True
			else:
				diff = diff and str(x)[j] != str(x)[k]
	return diff
for a in range(1000, 9013):
	if valid(a) and a > y:
		if yay == 0:
			print(a)
			yay = 1
		else:
			break


arr = list(input())
i = int(''.join(arr)) + 1
arr = list(str(i))
while 1:
	if arr[0] == arr[1] or arr[0] == arr[2] or arr[0] == arr[3] or (arr[1] == arr[2]) or (arr[1] == arr[3]) or (arr[2] == arr[3]):
		i = int(''.join(arr)) + 1
		arr = list(str(i))
	else:
		break
print(''.join(arr))


n = str(input())
i = 0
n = int(n) + 1
n = str(n)
while i == 0:
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		i = 1
	else:
		n = int(n) + 1
		n = str(n)
print(n)


n = int(input())
n += 1
x = str(n)
while x.count(x[0]) != 1 or x.count(x[1]) != 1 or x.count(x[2]) != 1:
	n += 1
	x = str(n)
print(n)


def isUnique(num):
	s1 = [str(i) for i in str(num)]
	s2 = set(s1)
	return len(s1) == len(s2)

def go(t):
	t += 1
	while True:
		if isUnique(t):
			return t
		t += 1
	return
t = int(input())
print(go(t))


n = int(input()) + 1
y = str(n)
while True:
	hashlist = {}
	flag = 0
	for i in y:
		if i not in hashlist:
			hashlist[i] = 1
		else:
			flag = 1
			break
	if flag == 0:
		break
	else:
		n += 1
		y = str(n)
print(n)


def number(n):
	ll = list()
	while n != 0:
		k = n % 10
		ll.append(k)
		n = n // 10
	return ll
n = int(input())
for i in range(n + 1, 9999):
	s = set()
	lk = number(i)
	x = 0
	for j in range(len(lk)):
		s.add(lk.count(lk[j]))
	if max(s) == 1:
		x = 1
		k = i
		break
print(k)


a = int(input())
a = a + 1
if a == 1987:
	print('2013')
else:
	while 1:
		t = a
		t = list(str(t))
		y = set(t)
		if len(y) == 4:
			print(a)
			break
		a = a + 1


n = int(input())
n = n + 1
while 1:
	t = n
	l = []
	while t > 0:
		l.append(t % 10)
		t = t // 10
	l = l[::-1]
	if l[-1] == l[1] or l[-1] == l[0] or l[-1] == l[2]:
		n += 1
		continue
	elif l[-2] == l[1] or l[-2] == l[0]:
		n += 10
		a = n % 10
		n -= a
		continue
	elif l[-3] == l[0]:
		n += 100
		n -= n % 100
		continue
	else:
		break
print(n)


n = input()
while True:
	nums = [0] * 10
	n = str(int(n) + 1)
	for i in n:
		nums[int(i)] += 1
	if max(nums) <= 1:
		print(n)
		break


min_year = int(input())
year = min_year + 1
dist_year = 0
digits = ''
while dist_year == 0:
	year = str(year)
	for digit in year:
		if digit not in digits:
			digits += digit
	if len(digits) == 4:
		dist_year = year
		print(dist_year)
	else:
		year = int(year) + 1
		digits = ''


year = int(input())
while True:
	year += 1
	digits = [int(d) for d in str(year)]
	if len(set(digits)) == 4:
		print(year)
		break


def is_beautiful_year(year):
	s = [c for c in str(year)]
	digits = dict.fromkeys(s)
	return len(digits) == 4

def main():
	current = int(input())
	print(next((year for year in range(current + 1, 10000) if is_beautiful_year(year))))
main()


year = str(input())
loop = True
while loop:
	year = int(year) + 1
	year = str(year)
	test = 0
	for i in year:
		for y in year:
			if i == y:
				test += 1
	if test == 4:
		loop = False
print(year)


n = int(input())
n += 1
while True:
	digs = list(map(int, str(n)))
	s = set(map(int, str(n)))
	if len(digs) != len(s):
		n += 1
	else:
		break
print(n)


n = input()
n = str(int(n) + 1)

def alldistinct(n):
	for i in n:
		if n.count(i) > 1:
			break
	else:
		return True
while alldistinct(n) != True:
	n = str(int(n) + 1)
print(n)


n = int(input())

def is_wow(n):
	l = []
	f = True
	while n > 0:
		o = n % 10
		if o in l:
			f = False
		l.append(o)
		n = n // 10
	return f
for i in range(n + 1, 9100):
	if is_wow(i):
		print(i)
		break


y = int(input())
for n in range(1, 9000):
	x = y + n
	z = str(x)
	if z[0] != z[1] and z[0] != z[2] and (z[0] != z[3]) and (z[1] != z[2]) and (z[1] != z[3]) and (z[2] != z[3]):
		print(x)
		break
	else:
		c = 0


y = int(input())
while y >= 1000 or y <= 9000:
	y = y + 1
	flag = 0
	v = str(y)
	for i in range(len(v)):
		for j in range(i + 1, len(v)):
			if v[i] == v[j]:
				flag = 1
	if flag == 0:
		print(int(v))
		break


inp = int(input())
for i in range(inp + 1, 10000):
	strI = str(i)
	distinct = 1
	for j in range(4):
		if strI[j] in strI[j + 1:]:
			distinct = 0
			break
	if distinct == 1:
		print(i)
		break


year = int(input())
year = year + 1
y = str(year)
while y[0] == y[1] or y[0] == y[2] or y[0] == y[3] or (y[1] == y[2]) or (y[1] == y[3]) or (y[2] == y[3]):
	year = year + 1
	y = str(year)
print(y)


k = input()
m = int(k)
l = [int(x) for x in k]
j = set(l)
m = m + 1
k = str(m)
l = [int(x) for x in k]
j = set(l)
while len(j) != len(l):
	m = m + 1
	k = str(m)
	l = [int(x) for x in k]
	j = set(l)
print(m)


n = input()
year = int(n)
flag = 0
while flag == 0:
	year = year + 1
	b = str(year)
	setn = set(b)
	if len(setn) == 4:
		flag = 1
	else:
		pass
print(year)


import sys
b = input()
c = int(b) + 1
while 1:
	d = list(str(c))
	f = set(d)
	k = len(d) - len(f)
	if k == 0:
		print(c)
		sys.exit()
	if k > 0:
		c = c + 1


def f(n):
	if len(set(str(n))) == len(str(n)):
		return True
	return False
n = int(input()) + 1
while True:
	if f(n):
		print(n)
		break
	n += 1


def beautyYear(a):
	n1 = a % 10
	n2 = a // 10 % 10
	n3 = a // 100 % 10
	n4 = a // 1000
	return n1 != n2 and n1 != n3 and (n1 != n4) and (n2 != n3) and (n2 != n4) and (n3 != n4)
y = int(input())
while True:
	y += 1
	if beautyYear(y):
		break
print(y)


n = int(input())
flag = False
while not flag:
	n += 1
	m = n
	lis = set()
	while m > 0:
		lis.add(m % 10)
		m //= 10
	if len(lis) == 4:
		flag = True
print(n)


n = eval(input())
n += 1
n = str(n)
while n[0] == n[1] or n[0] == n[2] or n[0] == n[3] or (n[1] == n[2]) or (n[1] == n[3]) or (n[2] == n[3]):
	y = int(n) + 1
	n = str(y)
print(n)


n = int(input())
n = n + 1
while True:
	x = set(list(str(n)))
	if len(x) != 4:
		n += 1
	else:
		break
print(n)


year = int(input())

def checkCondition(year):
	st = str(year)
	return st[0] != st[1] and st[1] != st[2] and (st[2] != st[3]) and (st[0] != st[3]) and (st[0] != st[2]) and (st[1] != st[3])
year += 1
while checkCondition(year) == False:
	year += 1
print(year)


import sys
import math
s = int(input())
s += 1

def distinct(number):
	a = [0, 0, 0, 0]
	for i in range(4):
		a[i] = number % 10
		number = int(number / 10)
	if len(set(a)) != 4:
		return False
	else:
		return True
while distinct(s) == False:
	s += 1
print(s)


y = int(input())
y += 1
a = []
for i in str(y):
	a.append(i)
while a[0] == a[1] or a[2] == a[3] or a[0] == a[2] or (a[0] == a[3]) or (a[1] == a[3]) or (a[1] == a[2]):
	y += 1
	a = []
	for i in str(y):
		a.append(i)
print(y)


def checker(a):
	b = []
	while a != 0:
		if (a % 10 in b) == True:
			return 0
		else:
			b.append(a % 10)
			a = a // 10
	return 1
a = int(input())
while True:
	a = a + 1
	if checker(a) == 1:
		print(a)
		break


y = int(input())
(a, b, c, d) = (0, 0, 0, 0)
while a + b + c + d != 4:
	y += 1
	q = str(y)
	a = q.count(q[0])
	b = q.count(q[1])
	c = q.count(q[2])
	d = q.count(q[3])
print(y)


t = str(int(input()) + 1)
while t[0] == t[1] or t[0] == t[2] or t[0] == t[3] or (t[1] == t[2]) or (t[1] == t[3]) or (t[2] == t[3]):
	t = int(t)
	t += 1
	t = str(t)
print(int(t))


x = int(input()) + 1

def y(s):
	arr = []
	for i in str(s):
		if i in arr:
			return False
		arr.append(i)
	return True
while not y(x):
	x += 1
print(x)


for i in range(int(input()) + 1, 10 ** 9):
	if len(set(str(i))) == 4:
		print(i)
		break


n = int(input())
while n:
	n += 1
	l = list(map(int, str(n)))
	if len(l) == len(set(l)):
		strings = [str(i) for i in l]
		a_string = ''.join(strings)
		an_integer = int(a_string)
		print(an_integer)
		break


def se(x):
	b = []
	for j in range(4):
		y = int(x % 10)
		x /= 10
		b.append(y)
	if len(set(b)) == len(b):
		return True
a = int(input()) + 1
while True:
	if se(a) is True:
		print(a)
		exit()
	else:
		a += 1


n = int(input())
k = n + 1
while k > 0:
	x = set(list(str(k)))
	if len(x) == len(str(k)):
		print(k)
		break
	else:
		k = k + 1


n = int(input())
m = n + 1

def isDistinct(m):
	s = str(m)
	if s[0] in s[1:]:
		return False
	if s[1] in s[2:]:
		return False
	if s[2] == s[3]:
		return False
	return True
while isDistinct(m) == False:
	m += 1
print(m)


def func(n):
	d1 = n // 1000
	d2 = n // 100 - d1 * 10
	d4 = n % 10
	d3 = (n % 100 - d4) // 10
	if d1 == d2 or d1 == d3 or d1 == d4 or (d2 == d3) or (d2 == d4) or (d3 == d4):
		return False
	else:
		return True
n = int(input()) + 1
while not func(n):
	n += 1
print(n)


a = int(input())

def bea(a):
	a = list(str(a))
	c = len(a)
	i = 0
	j = 1
	while c - 1 > i:
		while c > j:
			if a[i] == a[j]:
				return 0
			j = j + 1
		j = 1
		i = i + 1
		j = j + i
	return 1
while bea(a + 1) != 1:
	a = a + 1
print(a + 1)


n = int(input())
while True:
	set1 = set()
	c = 0
	n += 1
	t = n
	while t != 0:
		set1.add(t % 10)
		c += 1
		t //= 10
	if len(set1) == c:
		print(n)
		break


a = int(input())
running = True
while running:
	a = a + 1
	A = list(str(a))
	B = set(A)
	if len(A) == len(B):
		running = False
	else:
		pass
print(a)


n = int(input())
k = n + 1
loop = True
while loop:
	u = k % 10
	t = k // 10 % 10
	h = k // 100 % 10
	th = k // 1000 % 10
	if u != t and u != h and (u != th) and (t != h) and (t != th) and (h != th):
		loop = False
	else:
		k += 1
print(k)


n = str(int(input()) + 1)
while True:
	aux = []
	ex = True
	for i in range(0, len(n)):
		if aux.count(n[i]) != 0:
			ex = False
			break
		else:
			aux.append(n[i])
	if ex:
		print(n)
		exit(0)
	else:
		n = str(int(n) + 1)


def unique(s):
	d = {}
	for i in s:
		try:
			d[i] += 1
		except KeyError:
			d[i] = 1
	for i in d.keys():
		if d[i] > 1:
			return False
	return True
year = input()
a = int(year) + 1
while not unique(str(a)):
	a += 1
print(a)


n = input()
for i in range(int(n) + 1, 90000):
	j = str(i)
	if len(set(j)) == 4:
		print(j)
		break


n = int(input())
state = False
y = list()
for i in range(8000):
	n = n + 1
	y = list(map(int, str(n)))
	y.sort()
	if y[0] == y[1] or y[1] == y[2] or y[2] == y[3]:
		pass
	else:
		print(n)
		break


q = int(input())
q += 1
while len({int(i) for i in str(q)}) != 4:
	q += 1
print(q)


year = int(input())

def isBeautifulYear(y):
	if len(set(y)) == len(y):
		return True
	else:
		return False
year += 1
while not isBeautifulYear(str(year)):
	year += 1
print(year)


x = int(input())
flag = True
while flag:
	x += 1
	x1 = set(list(str(x)))
	if len(x1) == 4:
		flag = False
		break
print(x)


y = int(input()) + 1
num = False
while not num:
	a = list(str(y))
	for x in a:
		if a.count(x) > 1:
			y += 1
			break
	else:
		num = y
print(num)


x = int(input()) + 1
y = str(x)
a = bool
s = 0
while 1:
	if y.count(y[s]) > 1:
		x += 1
		y = str(x)
		s = 0
	else:
		s += 1
	if s == len(y):
		break
print(x)


a = int(input())
b = a + 1
while b % 10 == b // 1000 or b // 10 % 10 == b // 100 % 10 or b % 10 == b // 100 % 10 or (b // 1000 == b // 10 % 10) or (b % 10 == b // 10 % 10) or (b // 100 % 10 == b // 1000):
	b += 1
print(b)


n = int(input())

def judge():
	s = str(n)
	a = 0
	for i in range(1, len(s)):
		for j in range(i):
			if s[i] == s[j]:
				a += 1
				return 1
			else:
				pass
	if a == 0:
		return 0
	else:
		pass
while n > 0:
	n += 1
	if judge() == 1:
		pass
	else:
		break
print(n)


x = int(input())
x = x + 1
for i in range(x, 9999):
	i = str(i)
	if i[0] in i[1:]:
		continue
	elif i[1] in i[2:]:
		continue
	elif i[2] in i[3]:
		continue
	else:
		print(i)
		break


class Code:

	def __init__(self):
		self.n = int(input())

	def process(self):
		year = self.n + 1
		while 1:
			if len(set(str(year))) == len(str(year)):
				print(year)
				break
			year += 1
code = Code()
code.process()


n = int(input())
if len(set(str(n))) == 4 and n < 1987:
	n += 1
	while len(set(str(n))) < 4:
		n += 1
	print(n)
else:
	n += 1
	while len(set(str(n))) < 4:
		n += 1
	print(n)


year = input()
year_ = int(year)
while True:
	year_ = year_ + 1
	year_str = str(year_)
	li = [year_str[0], year_str[1], year_str[2], year_str[3]]
	li_new = set(li)
	if len(li_new) == 4:
		print(year_)
		break


y = int(input())
while 1 == 1:
	y = y + 1
	s = str(y)
	a = s[0:1]
	b = s[1:2]
	c = s[2:3]
	d = s[3:4]
	if a != b and a != c and (a != d) and (c != b) and (d != b) and (c != d):
		print(s)
		exit()


n = int(input())

def distinct(n):
	n = str(n)
	a = list(n)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		return True
	return False
i = n + 1
while True:
	if distinct(i):
		print(i)
		break
	i += 1


def check(d):
	s = str(d)
	l = [c for c in s]
	for i in range(len(l)):
		x = l[i]
		for j in range(len(l)):
			if i == j:
				continue
			y = l[j]
			if x == y:
				return False
	return True
year = int(input()) + 1
while True:
	if check(year):
		print(year)
		break
	else:
		year += 1


my_year = int(input())
for x in range(my_year + 1, 9999):
	temp = []
	for y in str(x):
		if y not in temp:
			temp.append(y)
	if len(temp) == 4:
		print(x)
		break


def next_beautiful_year(year):
	is_beautiful = False
	while is_beautiful is not True:
		year += 1
		distinct_nums = 0
		for num in str(year):
			if str(year).count(num) == 1:
				distinct_nums += 1
		if distinct_nums == len(str(year)):
			return year

def main():
	y = int(input())
	next_year = next_beautiful_year(y)
	print(next_year)
main()


y = int(input())
i = 0
while True:
	i += 1
	year = [a for a in str(y + i)]
	unique_check = True
	for d1 in range(len(year)):
		for d2 in range(len(year)):
			if d1 != d2:
				if year[d1] == year[d2]:
					unique_check = False
					break
	if unique_check:
		print(''.join(year))
		break


def Distinct(y):
	y1 = str(y)
	if y1[0] != y1[1] and y1[0] != y1[2] and (y1[0] != y1[3]):
		if y1[1] != y1[2] and y1[1] != y1[3] and (y1[2] != y1[3]):
			return 1
	else:
		return 0

def Year(y):
	for i in range(y + 1, 1000000000000):
		if Distinct(i) == 1:
			return i
x = int(input())
print(Year(x))


n = int(input())
num = [0, 0, 0, 0]

def calc(x):
	num[0] = x // 1000
	x %= 1000
	num[1] = x // 100
	x %= 100
	num[2] = x // 10
	x %= 10
	num[3] = x
calc(n)
ans = 0
for i in range(n + 1, 10000):
	calc(i)
	if num[0] != num[1] and num[0] != num[2] and (num[0] != num[3]) and (num[1] != num[2]) and (num[1] != num[3]) and (num[2] != num[3]):
		ans = i
		break
print(ans)


def main():
	n = int(input())
	while True:
		n += 1
		if len(set(list(str(n)))) == 4:
			print(n)
			break
main()


def check(num, num2):
	year = str(num)
	year2 = str(num2)
	for i in range(0, len(year2)):
		for j in range(0, len(year2)):
			if i == j:
				continue
			elif year2[i] == year2[j]:
				return False
	return True

def main():
	num = int(input())
	plus = 1
	while not check(num, num + plus):
		plus += 1
	print(num + plus)
main()


a = int(input())
ls = [1000 * i + 100 * j + 10 * k + l for i in range(1, 9) for j in range(0, 10) for k in range(0, 10) for l in range(0, 10) if i != j and i != k and (i != l) and (j != k) and (j != l) and (k != l)]
ls.append(9012)
for i in ls:
	if i > a:
		print(i)
		break


number = int(input())
result = 0

def check(number):
	number = str(number)
	if number[0] != number[1] and number[0] != number[2] and (number[0] != number[3]) and (number[1] != number[2]) and (number[1] != number[3]) and (number[2] != number[3]):
		return True
	return False
while result == 0:
	number += 1
	if check(number):
		result = number
		print(number)
	continue


def isOK(year):
	a = year % 10
	b = int(year / 10) % 10
	c = int(year / 100) % 10
	d = int(year / 1000)
	if a != b and b != c and (c != d) and (a != c) and (a != d) and (b != d):
		return True
	else:
		return False
y = int(input()) + 1
while not isOK(y):
	y += 1
print(y)


y = input()
y = str(int(y) + 1)

def isDis(y):
	for char in y:
		if y.count(char) > 1:
			return False
	return True
while not isDis(y):
	y = str(int(y) + 1)
print(y)


n = int(input())
x = 0
while x == 0:
	n += 1
	a = []
	s = str(n)
	t = len(s)
	for i in range(t):
		if s[i] not in a:
			a.append(s[i])
	if len(a) == t:
		x += 1
		print(n)


n = input()
e = str(n)
if int(n) >= 1987 and int(n) < 2013:
	print(2013)
else:
	while 1:
		e = int(e) + 1
		e = str(e)
		e = list(e)
		y = set(e)
		if len(y) == 4:
			s = ''
			for i in e:
				s += i
			print(s)
			break
		s1 = ''
		for i in e:
			s1 += i
		e = s1


n = int(input())
for i in range(n + 1, 90050, 1):
	digits2 = [int(x) for x in str(i)]
	digits3 = set(digits2)
	if len(digits3) == len(digits2):
		print(i)
		break


num = int(input())
check = 0
test = 0
for i in range(num, 90001):
	check = i + 1
	test = set(str(check))
	if len(test) == 4:
		print(check)
		break


import math
z = int(input())
while True:
	z += 1
	if len(set(str(z))) == len(str(z)):
		break
print(z)


current = int(input())
while True:
	current += 1
	if len(set(list(str(current)))) == 4:
		break
print(current)


Y = int(input())
Y += 1
while True:
	countlist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in range(0, len(str(Y))):
		countlist[int(str(Y)[i])] += 1
	flag = True
	for i in range(0, 10):
		if countlist[i] >= 2:
			flag = False
			break
	if flag:
		print(Y)
		break
	Y += 1


def isBeautiful(n):
	x = set()
	for i in str(n):
		x.add(i)
	return len(x) == 4
s = int(input())
while True:
	s += 1
	if isBeautiful(s):
		print(s)
		exit()


year = int(input())
a = 0
while a == 0:
	year += 1
	s_year = list(str(year))
	s_year = set(s_year)
	if len(s_year) > 3:
		a = 1
print(year)


n = int(input())
x = n + 1
while x > n:
	x = str(x)
	c = 0
	for i in x:
		if x.count(i) > 1:
			c += 1
	if c == 0:
		print(x)
		break
	else:
		x = int(x) + 1


n = int(input())
newN = str(n + 1)
while True:
	if len(set(newN)) == 4:
		print(newN)
		break
	else:
		m = int(newN)
		newN = str(m + 1)


x = int(input())
bl = False
x += 1
while bl == False:
	tracker = []
	for i in str(x):
		if i in tracker:
			x += 1
			break
		elif len(tracker) == 3 and i not in tracker:
			bl = True
			print(x)
		else:
			tracker.append(i)


year = int(input()) + 1

def is_beau(year):
	nums = set()
	for i in str(year):
		if i in nums:
			return -1
		nums.add(i)
	return 1
while is_beau(year) != 1:
	year += 1
print(year)


a = input()
i = 1
while i > 0:
	c = set()
	b = int(a)
	b = b + 1
	a = str(b)
	c.update(a)
	if len(c) == 4:
		print(a)
		break
	i += 1


def read():
	return int(input())

def distinct_digits(n):
	v = []
	for i in range(10):
		v.append(0)
	ok = True
	while n > 0 and ok == True:
		v[n % 10] += 1
		if v[n % 10] > 1:
			ok = False
		else:
			n = n // 10
	return ok

def find(n):
	n += 1
	while distinct_digits(n) != True:
		n += 1
	return n
n = read()
print(find(n))


y = int(input())
x = str(y + 1)
while x.count(x[0]) > 1 or x.count(x[1]) > 1 or x.count(x[2]) > 1:
	x = str(int(x) + 1)
print(x)


def thou(x):
	return x // 1000

def hun(x):
	return (x - 1000 * thou(x)) // 100

def ten(x):
	return x % 100 // 10

def dig(x):
	return x % 10
x = int(input()) + 1
i = 0
while i == 0:
	if thou(x) != hun(x) and hun(x) != ten(x) and (ten(x) != dig(x)) and (thou(x) != ten(x)) and (hun(x) != dig(x)) and (thou(x) != dig(x)):
		i = 1
	else:
		x += 1
print(x)


n = input()
s = list(n)
for i in range(int(n) + 1, 1000000):
	p = list(str(i))
	if len(set(p)) == len(p):
		print(i)
		break


n = int(input())
different_digits = True
while different_digits:
	for i in range(n + 1, 10000):
		i = str(i)
		i2 = (i[0], i[1], i[2], i[3])
		i2 = set(i2)
		if len(i2) == 4:
			print(i)
			exit()


import re
o = int(input())
run = True
while run:
	a = 0
	o += 1
	p = str(o)
	for i in range(10):
		if p.find(str(i)) != -1:
			a += 1
	if a == len(p):
		run = False
print(o)


n = int(input())
while n:
	n += 1
	if len(''.join(list(set(list(str(n)))))) == len(str(n)):
		print(n)
		exit(0)


def unique(number):
	str_number = str(number)
	if len(set(str(number))) == len(str_number):
		return 'True'
	else:
		return 'False'
Uin = int(input())
x = Uin + 1
while unique(x) == 'False':
	x = x + 1
print(x)


n = int(input())

def distinct(t):
	t = set(list(str(t)))
	return len(t)
while distinct(n + 1) != 4:
	n = n + 1
print(n + 1)


__author__ = 'DeyerliQiz'
import math

def isDistinct(x):
	return len(str(x)) == len(set(str(x)))
y = int(input())
x = y + 1
while True:
	if isDistinct(x):
		print(x)
		exit()
	x += 1


def years(year):
	a = set()
	i = year + 1
	while True:
		for j in range(4):
			if str(i)[j] not in a:
				a.add(str(i)[j])
		if len(a) == 4:
			return i
		else:
			a.clear()
			i += 1
year = int(input())
print(years(year))


def main():
	y = int(input())
	n = y + 1
	l = list(str(n))
	dd = False
	while dd == False:
		if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
			print(str(l[0] + l[1] + l[2] + l[3]))
			dd = True
		else:
			n += 1
			l = list(str(n))
main()


s = int(input()) + 1
while len(str(s)) > len(set(str(s))):
	s += 1
else:
	print(s)


n = int(input())
n += 1
j = list(str(n))
l = [i for i in j if j.count(i) > 1]
while len(l) != 0:
	n += 1
	j = list(str(n))
	l = [i for i in j if j.count(i) > 1]
print(n)


n = int(input())
arr = ''
while len(arr) != 4:
	n += 1
	arr = set(str(n))
print(n)


a = int(input())
S = []
for i in range(9999):
	if i >= 1000:
		S.append(i)
for i in S:
	p = str(i)
	if i > a and p[0] != p[1] and (p[0] != p[2]) and (p[0] != p[3]) and (p[1] != p[2]) and (p[1] != p[3]) and (p[2] != p[3]):
		print(i)
		break


def dif_digits(n):
	dig = set()
	while n > 0:
		if n % 10 in dig:
			return False
		dig.add(n % 10)
		n //= 10
	return True
N = int(input())
res = N + 1
while not dif_digits(res):
	res += 1
print(res)


n = int(input())
c = 0
while True:
	n = n + 1
	s = str(n)
	for i in range(len(s)):
		if s[i] in s[i + 1:]:
			break
	else:
		c = 1
		print(n)
	if c == 1:
		break


def unique(number):
	List = []
	while number != 0:
		Mod = number % 10
		if Mod in List:
			return False
		List.append(Mod)
		number = int(number / 10)
	return True
now = int(input())
year = now + 1
while year < 9013:
	if unique(year):
		print(year)
		exit(0)
	else:
		year += 1


n = input()
while True:
	D = dict()
	n = str(int(n) + 1)
	for i in list(n):
		D[i] = 0
	if len(D) == 4:
		print(n)
		exit(0)


y = int(input())
while 1:
	y += 1
	s = y
	bo = 0
	num = []
	while s != 0:
		if s % 10 in num:
			bo = 1
		else:
			num.append(s % 10)
		s = s // 10
	if bo == 0:
		print(y)
		break


n = int(input())
n = n + 1
while True:
	nn = str(n)
	st = set([])
	st.add(nn[0])
	st.add(nn[1])
	st.add(nn[2])
	st.add(nn[3])
	if len(st) == 4:
		print(n)
		break
	n = n + 1


year = int(input())
while True:
	year += 1
	a = year // 1000
	b = year // 100 % 10
	c = year // 10 % 10
	d = year % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
	else:
		pass
print(year)


b = int(input())
while b < 9500:
	b = b + 1
	a1 = b // 1000
	a2 = (b - a1 * 1000) // 100
	a3 = (b - a1 * 1000 - a2 * 100) // 10
	a4 = b - a1 * 1000 - a2 * 100 - a3 * 10
	if a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a2 != a4 != a3 != a4):
		break
print(b)


n = int(input())
x = n + 1
while True:
	l = len(str(x))
	if len(set(str(x))) == l:
		print(x)
		break
	else:
		x += 1


y = int(input())
niz = '1234567890'
broj = 0
while broj != 4:
	broj = 0
	y = y + 1
	for i in niz:
		if i in str(y):
			broj = broj + 1
print(y)


import itertools

def isuni(x):
	for i in itertools.count(x + 1):
		a = str(i)
		a = list(a)
		a = [int(u) for u in a]
		if len(a) == len(set(a)):
			break
	return i
x = int(input())
print(isuni(x))


y2 = int(input())
while True:
	y2 += 1
	if list(str(y2))[0] != list(str(y2))[1] and list(str(y2))[0] != list(str(y2))[2] and (list(str(y2))[0] != list(str(y2))[3]):
		if list(str(y2))[1] != list(str(y2))[2] and list(str(y2))[1] != list(str(y2))[3]:
			if list(str(y2))[2] != list(str(y2))[3]:
				break
print(y2)


n = int(input())
d = 1
n = n + 1
while 1:
	n = str(n)
	d = 1
	for i in range(0, len(n)):
		p = n.count(n[i])
		if p > 1:
			n = int(n)
			n = n + 1
			n = str(n)
			d = 0
	if d == 1:
		print(n)
		break


start = str(input())
var = True
allnums = []
while True:
	start = str(int(start) + 1)
	nums = list(start)
	for x in nums:
		if x not in allnums:
			allnums.append(x)
		else:
			allnums = []
			break
	if len(allnums) == len(nums):
		break
print(start)


y = int(input())
while True:
	y += 1
	s = str(y)
	if s[0] not in s[1:] and s[1] not in s[2:] and (s[2] not in s[3]):
		break
print(y)


yr = int(input())
yr += 1
g = str(yr)
while g[0] == g[1] or g[0] == g[2] or g[0] == g[3] or (g[1] == g[2]) or (g[1] == g[3]) or (g[2] == g[3]):
	g = str(int(g) + 1)
print(g)


year = input()
yearflag = 1
while yearflag != 0:
	flag = 1
	year = str(int(year) + 1)
	for x in range(0, 4):
		for y in range(x + 1, 4):
			if year[x] == year[y]:
				flag = 0
				break
	if flag == 1:
		yearflag = 0
print(year)


def beautiful_year(n):
	while True:
		n += 1
		s = set(str(n))
		if len(s) == 4:
			return n
n = int(input())
print(beautiful_year(n))


def f(n):
	a = []
	while n:
		if n % 10 in a:
			return False
		else:
			a.append(n % 10)
			n //= 10
	return True
n = int(input()) + 1
while not f(n):
	n += 1
print(n)


n = input()
k = len(n)
c = str(int(n) + 1)
while k != len(set(c)):
	c = str(int(c) + 1)
print(c)


def is_ok(x: int) -> bool:
	d = []
	for i in range(4):
		d.append(x % 10)
		x //= 10
	if d[0] != d[1] and d[0] != d[2] and (d[0] != d[3]) and (d[1] != d[2]) and (d[1] != d[3]) and (d[2] != d[3]):
		return True
	return False
y = int(input())
i = y + 1
while True:
	if is_ok(i):
		print(i)
		break
	i += 1


n = int(input())
n += 1
while 1:
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000 % 10
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		n += 1
	else:
		print(n)
		break


n = int(input())
while n != 0:
	n = n + 1
	lst = [int(x) for x in str(n)]
	if len(set(lst)) == len(lst):
		for i in lst:
			print(i, end='')
		break


a = int(input())
b = 1
while b == 1:
	a = a + 1
	if str(a)[0] != str(a)[1] and str(a)[0] != str(a)[2] and (str(a)[0] != str(a)[3]) and (str(a)[1] != str(a)[3]) and (str(a)[1] != str(a)[2]) and (str(a)[1] != str(a)[3]) and (str(a)[2] != str(a)[3]):
		b = b + 1
print(a)


import sys
y = int(input())
for i in range(y + 1, 10000):
	a = int(i % 10)
	b = int(int(i / 10) % 10)
	c = int(int(i / 100) % 10)
	d = int(int(i / 1000) % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		sys.exit(0)


a = int(input())
a = a + 1

def k(a):
	while len(str(a)) != len(set(str(a))):
		a += 1
	else:
		return a
k(a)
print(k(a))


y = int(input())
found = False
while not found:
	y += 1
	x = str(y)
	ans = 1
	for m in range(3):
		if x.count(x[m]) != 1:
			ans = 0
			break
	if ans == 1:
		print(x)
		found = True


def dlina(g):
	return len(set(str(g)))

def mingod(x):
	for i in range(x, 10000):
		if dlina(i) == 4 and i > x:
			return i
print(mingod(int(input())))


n = int(input())
loop = True
while loop:
	l = []
	n += 1
	for x in list(str(n)):
		if x not in l:
			l.append(x)
	if len(l) == 4:
		break
print(*l, sep='')


n = int(input())
answer = 0
while answer == 0:
	n = int(n)
	n += 1
	n = str(n)
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		answer = n
		print(answer)
	continue


year = int(input())
while True:
	year += 1
	nyear = str(year)
	digits = []
	for char in nyear:
		if char not in digits:
			digits.append(char)
		else:
			break
	if len(digits) == 4:
		print(nyear)
		exit()


a = int(input())
while True:
	b = a + 1
	l = []
	while b > 0:
		l.append(b % 10)
		b = b // 10
	if len(set(l)) == 4:
		print(a + 1)
		break
	else:
		a += 1


y = str(int(input()) + 1)

def proverka(s):
	for i in s:
		if s.count(i) > 1:
			return str(int(s) + 1)
	return s
while proverka(y) > y:
	y = str(int(y) + 1)
print(y)


tahun = int(input())
cek = False
while cek == False:
	tahun += 1
	data = []
	coba = str(tahun)
	for i in range(len(coba)):
		data += [int(coba[i])]
	for i in range(len(data)):
		for j in range(i + 1, len(data)):
			if data[i] == data[j]:
				cek = False
				break
			else:
				cek = True
		if cek == False:
			break
print(tahun)


def isDistinct(nYear, year):
	x = set(list(nYear))
	if len(x) >= len(list(year)):
		return True
	return False
year = input()
while True:
	if isDistinct(str(int(year) + 1), year) == True:
		year = str(int(year) + 1)
		break
	year = str(int(year) + 1)
print(year)


def distinct(n):
	n += 1
	m = n
	while True:
		lst = []
		m = list(str(m))
		for i in range(len(m)):
			if m[i] not in lst:
				lst.append(m[i])
		if len(lst) == len(str(n)):
			return n
		n += 1
		m = n
t = int(input())
print(distinct(t))


year = int(input())
y = year + 1
while y > year:
	y_list = list(str(y))
	a = y_list[0]
	b = y_list[1]
	c = y_list[2]
	d = y_list[3]
	if y_list.count(a) > 1 or y_list.count(b) > 1 or y_list.count(c) > 1 or (y_list.count(d) > 1):
		y += 1
	else:
		break
print(y)


x = int(input())
y = [0] * 256
x += 1
while True:
	for i in str(x):
		y[ord(i)] = 1
	z = y.count(1)
	if z != 4:
		y = [0] * 256
		z = 0
		x += 1
	else:
		print(x)
		break


def check_digit(year):
	for i in range(0, 4):
		if year.count(year[i]) > 1:
			return False
	return True
y = int(input())
y = y + 1
while not check_digit(str(y)):
	y = y + 1
print(y)


def isUnique(num):
	arr = [None for i in range(10)]
	num1 = str(num)
	for i in range(len(num1)):
		if not arr[int(num1[i])]:
			arr[int(num1[i])] = 1
		else:
			return False
	return True
n = int(input())
k = n + 1
while True:
	if isUnique(k):
		print(k)
		break
	k += 1


n = int(input())
for i in range(n + 1, 9013):
	d = dict()
	x = i
	k = 0
	while x > 0:
		y = x % 10
		if y in d:
			k = 1
			break
		else:
			d[y] = 0
		x = x // 10
	if k == 0:
		break
print(i)


n = input()
n = int(n) + 1
n = str(n)
while True:
	a = []
	for i in range(4):
		a.append(n[i])
	if int(a[0]) != int(a[1]) and int(a[0]) != int(a[2]) and (int(a[0]) != int(a[3])) and (int(a[1]) != int(a[2])) and (int(a[1]) != int(a[3])) and (int(a[2]) != int(a[3])):
		break
	else:
		n = int(n) + 1
		n = str(n)
for i in range(4):
	print(a[i], end='')


def is_beautiful(y):
	have = [0] * 10
	while y != 0:
		mod = y % 10
		if have[mod]:
			return False
		else:
			have[mod] = True
		y = int(y / 10)
	return True
year = int(input())
i = 0
for i in range(year + 1, 10000):
	if is_beautiful(i):
		break
print(i)


k = int(input())

def nihao(n):
	a = []
	for i in range(len(n)):
		if n[i] not in a:
			a.append(n[i])
	if len(a) == len(n):
		return 1
	else:
		return 0
for i in range(k + 1, 9013):
	if nihao(str(i)):
		print(i)
		break


x = int(input())
while 1000 <= x <= 90000:
	x = x + 1
	z = str(x)
	if z[0] == z[1] or z[0] == z[2] or z[0] == z[3] or (z[1] == z[2]) or (z[1] == z[3]) or (z[2] == z[3]):
		continue
	elif not (z[0] == z[1] or z[0] == z[2] or z[0] == z[3] or (z[1] == z[2]) or (z[1] == z[3]) or (z[2] == z[3])):
		print(int(z))
		break


def distinct_digits(year):
	str_year = str(year)
	my_nums = {}
	for char in str_year:
		if char in my_nums:
			my_nums[char] += 1
		else:
			my_nums[char] = 1
	for value in my_nums.values():
		if value > 1:
			return False
	return True
year = int(input()) + 1
while not distinct_digits(year):
	year += 1
print(year)


def beautiful_year(n):
	year = n + 1
	while year <= 9000:
		if len(list(str(year))) == len(set(list(str(year)))):
			return year
		year += 1
	return 9012
n = int(input())
print(beautiful_year(n))


n = int(input()) + 1
while 1:
	nn = []
	for i in str(n):
		nn.append(int(i))
	if len(nn) == len(set(nn)):
		print(n)
		break
	n += 1


n = int(input())
while True:
	n += 1
	if n > 9012:
		break
	d = {}
	f = 1
	for i in str(n):
		if i not in d.keys():
			d[i] = 1
		else:
			f = 0
			break
	if f == 0:
		continue
	else:
		print(n)
		break


y = int(input()) + 1
flag = 0
while flag == 0:
	sy = str(y)
	c = 0
	for a in sy:
		if sy.count(a, 0, len(sy)) == 1:
			c += 1
	if c == 4:
		flag = 1
		break
	else:
		y += 1
if flag == 1:
	print(str(y))


try:
	k = int(input()) + 1
	while len(set(str(k))) < 4:
		k += 1
	print(k)
except:
	pass


s = input()
while True:
	d = dict()
	s = int(s) + 1
	for i in str(s):
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	if len(d) == 4:
		print(int(s))
		break


from functools import *
n = int(input())
while True:
	n += 1
	j = list(str(n))
	w = set(j)
	if len(j) == len(w):
		print(reduce(lambda i, k: i + k, j))
		break


n = int(input())
ok = False
curr = n
while not ok:
	curr = curr + 1
	count = [0] * 10
	tmp = curr
	while tmp > 0:
		count[tmp % 10] += 1
		if count[tmp % 10] >= 2:
			break
		tmp = tmp // 10
	if all((elm <= 1 for elm in count)):
		ok = True
print(curr)


def dis(n):
	if n[0] == n[1] or n[0] == n[2] or n[0] == n[3] or (n[1] == n[2]) or (n[1] == n[3]) or (n[2] == n[3]):
		f = False
	else:
		f = True
	return f
l = int(input())
while True:
	l += 1
	m = dis(str(l))
	if m == True:
		print(l)
		break


y = input()
if y == '1987':
	print('2013')
else:
	while True:
		y = int(y) + 1
		y = str(y)
		if y.count(y[0]) == 1 and y.count(y[1]) == 1 and (y.count(y[2]) == 1) and (y.count(y[3]) == 1):
			print(y)
			break


def is_year_beautiful(year):
	year_string = str(year)
	year_digits = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
	for char in year_string:
		if year_digits[char] <= 0:
			year_digits[char] += 1
		else:
			return False
	return True
y = input()
y_int = int(y)
beautiful_year = y_int + 1
while not is_year_beautiful(beautiful_year):
	beautiful_year += 1
print(beautiful_year)


y = eval(input(''))
if y >= 1000 and y <= 9000:
	while 1:
		y += 1
		n1 = y // 1000
		n2 = y % 1000 // 100
		n3 = y % 100 // 10
		n4 = y % 10
		if n1 != n2 and n1 != n3 and (n1 != n4) and (n2 != n3) and (n2 != n4) and (n3 != n4):
			break
	print(str(n1) + str(n2) + str(n3) + str(n4))


y = int(input())
while 1:
	y += 1
	i = y
	s = set()
	while i > 0:
		s.add(i % 10)
		i //= 10
	if len(s) == 4:
		print(y)
		break


n = int(input())
n += 1
for i in range(1, 9000):
	l = list(str(n))
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
		print(n)
		exit()
	else:
		n += 1


from math import *

def main():
	y = int(input())
	ans = False
	while not ans:
		y += 1
		cs = ''
		for c in str(y):
			if c not in cs:
				cs += c
			else:
				break
		if cs == str(y):
			ans = True
	print(y)
main()


x = int(input())
x = x + 1
import math
First = math.floor(x / 1000)
Second = math.floor((x - First * 1000) / 100)
Third = math.floor((x - First * 1000 - Second * 100) / 10)
Fourth = x - First * 1000 - Second * 100 - Third * 10
while True:
	if First == Second or First == Third or First == Fourth or (Second == Third) or (Second == Fourth) or (Third == Fourth):
		if Fourth != 9:
			Fourth = Fourth + 1
		elif Fourth == 9 and Third == 9 and (Second == 9):
			Fourth = 0
			Third = 0
			Second = 0
			First = First + 1
		elif Fourth == 9 and Third == 9:
			Fourth = 0
			Third = 0
			Second = Second + 1
		else:
			Fourth = 0
			Third = Third + 1
	else:
		break
print(First * 1000 + Second * 100 + Third * 10 + Fourth)


n = int(input())
for i in range(n + 1, n + 1000):
	x = str(i)
	if x.count('1') < 2 and x.count('2') < 2 and (x.count('3') < 2) and (x.count('4') < 2) and (x.count('5') < 2) and (x.count('6') < 2) and (x.count('7') < 2) and (x.count('8') < 2) and (x.count('9') < 2) and (x.count('0') < 2):
		print(x)
		break


l = input()
for m in range(int(l) + 1, 100000 + 1):
	A = [0 for _ in range(10)]
	for i in range(len(A)):
		A[i] = str(m).count(str(i))
	if all((x == 1 or x == 0 for x in A)):
		print(m)
		break


n = int(input())
L = [0] * 4
while True:
	n += 1
	L[3] = n // 1000
	L[2] = n // 100 % 10
	L[1] = n // 10 % 10
	L[0] = n % 10
	if len(set(L)) == 4:
		break
print(n)


y = int(input()) + 1
while y < 9012:
	a = str(y)
	(p, q, r, l) = (a[0], a[1], a[2], a[3])
	if p == q or p == r or p == l or (q == r) or (q == l) or (r == l):
		y += 1
	else:
		break
print(y)


def year(god):
	god += 1
	a = str(god)
	b = set(a)
	while len(b) == 2 or len(b) == 3 or len(b) == 1:
		god += 1
		a = str(god)
		b = set(a)
	return god
print(year(int(input())))


x = int(input(' '))
a = x
while True:
	V = []
	z = x
	while z != 0:
		V.append(z % 10)
		z = z // 10
	isUnique = True
	for i in V:
		if i in V[V.index(i) + 1:]:
			isUnique = False
	if isUnique and x != a:
		print(x)
		break
	else:
		x += 1


def isGood(n):
	n = str(n)
	n = list(n)
	out = []
	for char in n:
		if char not in out:
			out.append(char)
	return len(out) == len(n)
y = int(input())
ans = 0
i = y + 1
while not isGood(i):
	i += 1
print(i)


def beautifulYear():
	y = int(input())
	while 1:
		y += 1
		a = y // 1000
		b = y // 100 % 10
		c = y // 10 % 10
		d = y % 10
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			print(y)
			break

def main():
	beautifulYear()
main()


def findYear(x):
	x = x + 1
	v = list(str(x))
	while len(set(v)) != 4:
		x = x + 1
		v = list(str(x))
	return x
print(findYear(int(input())))


y = int(input())

def by(y):
	for i in y:
		if y.count(i) > 1:
			return False
	return True
while True:
	y += 1
	if by(str(y)):
		print(y)
		break


n = input()
for i in range(9000):
	n = str(int(n) + 1)
	t = [n[0], n[1], n[2], n[3]]
	if len(set(t)) == 4:
		print(n)
		break


g = int(input())
while True:
	g += 1
	t = str(g)
	if t[0] not in (t[1], t[2], t[3]) and t[1] not in (t[0], t[2], t[3]) and (t[2] not in (t[1], t[0], t[3])) and (t[3] not in (t[1], t[2], t[0])):
		break
print(g)


y = int(input())

def is_distinct(num: int):
	s = [c for c in str(num)]
	for i in range(10):
		if s.count(str(i)) > 1:
			return False
	return True
while True:
	y += 1
	if is_distinct(y):
		print(y)
		break


y = int(input())
while True:
	y = y + 1
	z = list(str(y))
	x = set(map(int, str(y)))
	if len(x) == len(z):
		print(y)
		break


n = int(input())
n += 1
ctr = 0

def i2l(k):
	x = []
	while k > 0:
		t = k % 10
		x.append(t)
		k = k // 10
	x.reverse()
	return x
while 1000 <= n <= 9100:
	i = []
	i = i2l(n)
	for j in range(4):
		for k in range(4):
			if i[j] == i[k] and j != k:
				ctr += 1
	if ctr == 0:
		break
	else:
		n += 1
		ctr = 0
print(n)


def check(n):
	lst = []
	temp = n
	while temp > 0:
		lst.append(temp % 10)
		temp //= 10
	unique = set(lst)
	if len(unique) == len(str(n)):
		return True
	else:
		return False
n = int(input())
while True:
	n += 1
	if check(n):
		break
print(n)


def distinct_num(year):
	unique_year = 0
	new_year = year
	while unique_year == 0:
		checker = []
		new_year += 1
		for i in range(len(str(new_year))):
			if str(new_year)[i] in checker:
				break
			else:
				checker.append(str(new_year)[i])
		if len(checker) == 4:
			unique_year = int(''.join(checker))
	return unique_year
year = int(input())
print(distinct_num(year))


year = int(input())
c = 0
while c < 4:
	year_d = year + 1
	t = str(year_d)
	year_set = set(list(t))
	c = len(year_set)
	year = year + 1
print(year_d)


n = int(input())
x = list(map(int, str(n)))
ny = set()
for i in x:
	ny.add(i)
if len(ny) == len(x):
	n = n + 1
	x = list(map(int, str(n)))
	ny = set()
	for i in x:
		ny.add(i)
while len(ny) != len(x):
	x = list(map(int, str(n)))
	ny = set()
	for i in x:
		ny.add(i)
	n = n + 1
for j in x:
	print(j, end='')


import math

def get_num():
	return list(map(int, input().rstrip().split()))

def isLucky(num):
	array = [0] * 10
	while num > 1:
		digit = math.floor(num % 10)
		if array[digit]:
			return 0
		array[digit] = 1
		num = num / 10
	return 1

def main():
	num = int(input())
	num += 1
	var = isLucky(num)
	while var == 0:
		num += 1
		var = isLucky(num)
	print(num)
main()


year = int(input())
while True:
	year += 1
	hash = {}
	for ch in str(year):
		hash[ch] = 0
	if len(hash) == 4:
		print(year)
		break


y = int(input())
for i in range(y + 1, 9013):
	strI = str(i)
	if strI[0] != strI[1]:
		if strI[0] != strI[2]:
			if strI[0] != strI[3]:
				if strI[1] != strI[2]:
					if strI[1] != strI[3]:
						if strI[2] != strI[3]:
							print(i)
							break


def Sol(y):
	ans = int(y) + 1
	while len(set(str(ans))) != len(y):
		ans += 1
	print(ans)
	return
que = input()
Sol(que)


x = int(input())
flag = 0
while flag == 0:
	x = x + 1
	temp = x
	arr = []
	for i in range(10):
		arr.append(0)
	while temp > 0:
		arr[temp % 10] = arr[temp % 10] + 1
		temp = temp // 10
	for i in range(10):
		if arr[i] > 1:
			flag = 0
			break
		elif arr[i] is 1:
			flag = 1
	if temp > 9000:
		break
print(x)


year = input()
new_year = year
while True:
	new_year = str(int(new_year) + 1)
	ok = True
	for no in new_year:
		cnt = new_year.count(no)
		if cnt > 1:
			ok = False
			break
	if ok:
		break
print(new_year)


yearNumber = int(input())
yearNumber = yearNumber + 1
while True:
	a = list(str(yearNumber))
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		break
	else:
		yearNumber = yearNumber + 1
print(yearNumber)


y = int(input())
y += 1
active = True
while active == True:
	year = []
	for i in str(y):
		year.append(i)
	distinct = True
	i = 0
	while distinct and i < len(year):
		j = i + 1
		while distinct and j < len(year):
			if year[i] == year[j]:
				distinct = False
			j += 1
		i += 1
	if distinct == True:
		active = False
	else:
		y += 1
print(y)


year = int(input())

def dupc(year):
	conv = str(year)
	seet = []
	for i in conv:
		if not i in seet:
			seet.append(i)
	if len(seet) == len(conv):
		return year
	else:
		return dupc(year + 1)
print(dupc(year + 1))


n = int(input())
for i in range(n, 900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000):
	c1 = i % 10
	c2 = i // 10 % 10
	c3 = i // 100 % 10
	c4 = i // 1000
	if n < i and c1 != c2 and (c1 != c3) and (c1 != c4) and (c2 != c3) and (c2 != c4) and (c3 != c4):
		print(i)
		break


def check(x):
	x = str(x)
	x = list(x)
	l1 = len(x)
	x = set(x)
	l2 = len(x)
	if l1 == l2:
		return True
	else:
		return False
n = int(input())
n += 1
q = 1
while q != 0:
	if check(n):
		print(n)
		q = 0
	else:
		n += 1


n = int(input())
while 1:
	n += 1
	x = set(str(n))
	if len(x) == 4:
		print(n)
		break
	else:
		continue


year = int(input())
while 1 == 1:
	year += 1
	s = str(year)
	if s.count('0') <= 1 and s.count('1') <= 1 and (s.count('2') <= 1) and (s.count('3') <= 1) and (s.count('4') <= 1) and (s.count('5') <= 1) and (s.count('6') <= 1) and (s.count('7') <= 1) and (s.count('8') <= 1) and (s.count('9') <= 1):
		print(year)
		break


y = input()
y = int(y)
d = []
for x in range(1000, 10000):
	if len(set(str(x))) == len(str(x)):
		d.append(x)
n = len(d)
if y in d:
	print(d[d.index(y) + 1])
else:
	i = 0
	while i < n and y > d[i]:
		i += 1
	print(d[i])


tahun = int(input())
tahun_op = tahun + 1
if tahun < 1000 or tahun > 9000:
	exit()
stop = 0
while stop != 1:
	array_thn = list(map(int, str(tahun_op)))
	if len(array_thn) == len(set(array_thn)):
		jawab = tahun_op
		print(tahun_op)
		stop = 1
	else:
		tahun_op += 1


def binary_search(arr, low, high, x):
	mid = (high + low) // 2
	if high >= low:
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return mid
a = []
for i in range(1000, 9001):
	if len(set(str(i))) == len(str(i)):
		a.append(i)
n = int(input())
a.append(9012)
if n < a[0]:
	print(a[0])
else:
	s = binary_search(a, 0, len(a) - 1, n)
	for i in range(s, len(a)):
		if a[i] > n:
			print(a[i])
			break


val = int(input())
while val < 10000:
	val += 1
	k = set(list(str(val)))
	if len(k) == 4:
		print(val)
		break


n = int(input())
t = n + 1
while t > 0:
	x = [int(s) for s in str(t)]
	r = set(x)
	if len(r) == len(x):
		break
	t += 1
print(t)


x = int(input()) + 1
n = str(x)
while x < 10000:
	if len(set(n)) == len(n):
		print(x)
		break
	else:
		x += 1
		n = str(x)


n = int(input())
flag = 0
while flag == 0:
	n += 1
	a = str(n)
	if a[0] != a[1] and a[2] != a[1] and (a[2] != a[3]) and (a[0] != a[2]) and (a[0] != a[3]) and (a[1] != a[3]):
		ans = int(a)
		flag = 1
print(ans)


import math

def good(data):
	for i in range(4):
		for j in range(i + 1, 4):
			if data[i] == data[j]:
				return 0
	return 1

def plus(data, pos):
	if data[pos] < 9:
		data[pos] += 1
	else:
		data[pos] = 0
		plus(data, pos - 1)
data = list(input())
data = [int(data[i]) for i in range(4)]
plus(data, 3)
while not good(data):
	plus(data, 3)
for i in range(4):
	print(data[i], sep='', end='')
print()


y = int(input())
while not 1000 <= y <= 9000:
	y = int(input())
while True:
	y = y + 1
	a = y % 10
	b = y // 10 % 10
	c = y // 100 % 10
	d = y // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(y)


a = int(input()) + 1
while len(str(a)) != len(set(map(int, str(a)))):
	a += 1
print(a)


n = int(input()) + 1
count = 0
while count != 1:
	k = [int(x) for x in str(n)]
	setl = set(k)
	len1 = len(setl)
	len2 = len(k)
	if len1 != len2:
		n = n + 1
	else:
		count = 1
		print(n)


from collections import Counter
n = int(input())
while 1:
	flag = 0
	n += 1
	s = str(n)
	a = [i for i in s]
	values = list(dict(Counter(a)).values())
	for i in values:
		if i > 1:
			flag = 1
			break
	if flag == 1:
		continue
	else:
		break
print(n)


n = int(input())
while True:
	my_set = set()
	n += 1
	string_number = str(n)
	for i in string_number:
		my_set.add(i)
	if len(my_set) == 4:
		break
print(string_number)


def isLucky(number):
	distinctDigit = set()
	count = 0
	while number:
		count += 1
		distinctDigit.add(number % 10)
		number //= 10
	return len(distinctDigit) == count
number = int(input())
while True:
	number += 1
	if isLucky(number):
		print(number)
		break


n = int(input()) + 1
while n < 99999:
	m = n
	ok = 0
	arr = []
	while m > 0:
		r = m % 10
		if arr.count(r) > 0:
			ok = 1
			break
		else:
			arr.append(r)
		m = m // 10
	if ok == 1:
		n += 1
	else:
		break
print(n)


def digits(n):
	sett = set()
	while n:
		sett.add(n % 10)
		n //= 10
	return sett
n = int(input()) + 1
sett = digits(n)
while len(sett) < len(str(n)):
	n += 1
	sett = digits(n)
print(n)


n = int(input())
a = []
p = ''
j = n + 1
while j >= n + 1:
	a = []
	p = str(j)
	for i in range(len(p)):
		a.append(p[i])
	a = sorted(set(a))
	if len(a) == len(p):
		print(p)
		break
	j += 1


import sys
a = int(input())
while True:
	b = 0
	a = int(a)
	с = a + 1
	a = int(a)
	a += 1
	a = str(a)
	l = []
	for i in range(4):
		l.append(a[i])
	l.sort()
	for i in range(3):
		if l[i] == l[i + 1]:
			b += 1
	if b == 0:
		print(с)
		sys.exit()


a = int(input())
while True:
	a += 1
	if len({x for x in str(a)}) == 4:
		print(a)
		break


def isdistinct(year):
	judge = str(year)
	result = True
	for i in range(4):
		for j in range(i):
			if judge[i] == judge[j]:
				result = False
				break
	return result
year = int(input())
year += 1
while not isdistinct(year):
	year += 1
print(year)


import sys
Inpt = int(input())
for Count in range(Inpt + 1, 10 ** 5):
	if not Count // 1000 == Count // 100 % 10 and (not Count // 1000 == Count % 100 // 10) and (not Count // 1000 == Count % 10) and (not Count // 100 % 10 == Count % 100 // 10) and (not Count // 100 % 10 == Count % 10) and (not Count % 100 // 10 == Count % 10):
		print(Count)
		sys.exit()


year = int(input())
a = [int(i) for i in str(year)]
ans = 0
ans = year
while True:
	ans = int(ans)
	ans += 1
	ans = str(ans)
	ar = [i for i in ans]
	if len(set(ar)) >= len(a):
		string1 = ''
		string1 = ''.join(ar)
		print(string1)
		break


def solve(n):
	while n:
		a = n // 1000
		b = n // 100 % 10
		c = n // 10 % 10
		d = n % 10
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			print(n)
			return
		n += 1
n = int(input())
solve(n + 1)


num = int(input())
while True:
	num = num + 1
	r = set(map(int, str(num)))
	if len(r) == 4:
		print(num)
		break


def isValid(n):
	n = str(n)
	x = set()
	for i in n:
		x.add(i)
	if len(x) == len(n):
		return True
	return False
li = []
for i in range(1000, 10000):
	if isValid(i):
		li.append(i)

def binary(n):
	low = 0
	high = len(li) - 1
	ans = n
	while low <= high:
		mid = (low + high) // 2
		if li[mid] > n:
			ans = li[mid]
			high = mid - 1
		else:
			low = mid + 1
	return ans
n = int(input())
print(binary(n))


def jojo(x, snb):
	for i in range(10):
		if x.count(str(i)) == 0 or x.count(str(i)) == 1:
			snb += 1
	if snb == 10:
		return 1
	else:
		return 0
n = input()
sn = int(n)
for i in range(sn, 10000):
	ci = str(i + 1)
	ss = 0
	if jojo(ci, ss) == 1:
		print(ci)
		break


s = input()
a = int(s)
flag = 0
while flag != 1:
	a = a + 1
	t = str(a)
	tag = 1
	for i in range(len(t) - 1):
		for j in range(i + 1, len(t)):
			if t[i] == t[j]:
				tag = 0
				break
	if tag == 1:
		flag = 1
		output = t
	tag = 0
print(output)


def checking(year) -> int:
	year = int(year)
	year += 1
	while True:
		if len(list(str(year))) == len(set(str(year))):
			return year
		year += 1
a = input()
print(checking(a))


year = input('')
year = str(int(year) + 1)

def isUnique(year):
	map = {}
	for num in year:
		val = map.get(num)
		if val == None:
			map[num] = 1
		else:
			map[num] = val + 1
			return False
	return True
while isUnique(year) != True:
	year = str(int(year) + 1)
print(year)


a = input()
b = int(a)
b += 1
a = str(b)
c = set(a)
while len(c) < 4:
	b += 1
	del c
	a = str(b)
	c = set(a)
print(a)


def main():
	year = int(input().strip()) + 1
	count = len(set(list(str(year))))
	while count != 4:
		year = int(year) + 1
		count = len(set(list(str(year))))
	print(year)
main()


k = int(input())
l = 1
while l != 0:
	k += 1
	l = len(list(str(k))) - len(set(str(k)))
print(k)


x = input()
if x == '9000':
	print('9012')
else:
	for i in range(int(x) + 1, 20000):
		if str(i)[0] != str(i)[1] and str(i)[0] != str(i)[2] and (str(i)[0] != str(i)[3]) and (str(i)[1] != str(i)[2]) and (str(i)[1] != str(i)[3]) and (str(i)[2] != str(i)[3]):
			break
	print(i)


n = int(input())

def fun(n):
	n = list(str(n))
	t = True
	for i in range(4):
		for j in range(4):
			if i != j:
				if n[i] == n[j]:
					t = False
	return t
n += 1
while not fun(n):
	n += 1
print(n)


n = int(input())
a = []
while len(str(n)) == 4:
	n += 1
	d = str(n)
	if len(set(d)) == 4:
		a.append(d)
print(min(a))


year = str(int(input()) + 1)
digits = [int(x) for x in year]
count = []
for digit in digits:
	count.append(digits.count(digit))
while max(count) > 1:
	year = str(int(year) + 1)
	digits = [int(x) for x in year]
	count = []
	for digit in digits:
		count.append(digits.count(digit))
print(year)


year = int(input())

def isDistinct(num):
	list_num = []
	while num > 0:
		list_num.append(num % 10)
		num = int(num / 10)
	for i in range(0, len(list_num) - 1):
		for j in range(i + 1, len(list_num)):
			if list_num[i] == list_num[j]:
				return False
	return True
while isDistinct(year + 1) != True:
	year += 1
print(year + 1)


def beautiful(i):
	i = str(i)
	for j in range(0, len(i) - 1):
		if i[j] in i[j + 1:]:
			return False
	return True
y = int(input())
for i in range(y + 1, 10001):
	if beautiful(i):
		print(i)
		exit(0)


a = int(input())
while 1:
	f = 1
	a = a + 1
	b = str(a)
	for i in range(4):
		for j in range(i + 1, 4):
			if b[i] == b[j]:
				f = 0
				break
		if f == 0:
			break
	if f == 1:
		print(b)
		break
	else:
		a = int(b)


n = int(input())
numero = [0, 0, 0, 0]
for i in range(1000, 10000):
	if i > n:
		i = str(i)
		i = list(i)
		if i[0] != i[1] and i[0] != i[2] and (i[0] != i[3]) and (i[1] != i[2]) and (i[1] != i[3]) and (i[2] != i[3]):
			for p in range(4):
				numero[p] = int(i[p])
	if numero[0] != 0:
		break
for i in range(4):
	print(numero[i], end='')


y = int(input())
t = 1
while t == 1:
	t = 0
	y += 1
	x = str(y)
	for i in range(3):
		for j in range(i + 1, 4):
			if x[i] == x[j]:
				t = 1
print(y)


y = int(input())
y2 = y + 1
while len(set([i for i in str(y2)])) < 4:
	y2 += 1
print(y2)


def beaut(ans):
	ans = str(ans)
	vals = [ans.count(v) == 1 for v in ans]
	return all(vals)
n = int(input())
ans = n + 1
while not beaut(ans):
	ans += 1
print(ans)


def no_rep(num):
	num_str = str(num)
	hash = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for letter in num_str:
		hash[int(letter)] = hash[int(letter)] + 1
		if hash[int(letter)] > 1:
			return False
	return True
n = input()
n_int = int(n)
n_int = n_int + 1
while True:
	if no_rep(n_int):
		print(n_int)
		exit()
	n_int = n_int + 1


def is_distinct(number):
	number = str(number)
	n = len(str(number))
	for i in range(n):
		for j in range(n):
			if i < j and number[i] == number[j]:
				return False
	return True

def main():
	import sys
	year = int(sys.stdin.readline())
	candidate_year = year + 1
	while not is_distinct(candidate_year):
		candidate_year += 1
	sys.stdout.write(str(candidate_year))
main()


x = input()
while 1:
	x = int(x) + 1
	l = []
	for i in str(x):
		if i not in l:
			l.append(i)
	if len(l) == 4:
		print(x)
		break


n = int(input())
while True:
	n += 1
	ls = list(dict.fromkeys(list(str(n))))
	if len(ls) == 4:
		print(n)
		break


x = input()
while True:
	x = str(int(x) + 1)
	n = sorted(x)
	if n[0] != n[1] and n[1] != n[2] and (n[2] != n[3]):
		print(x)
		break


def check(x):
	return len(set(x)) == len(x)
x = int(input())
while True:
	x += 1
	if check(str(x)):
		print(x)
		exit(0)


def distinct(y):
	s = set()
	for i in str(y):
		s.add(i)
	return len(str(y)) == len(s)
y = int(input()) + 1
while not distinct(y):
	y += 1
print(y)


year = []
prin = int(input()) + 1
prin = str(prin)
while True:
	year = list(prin)
	year.sort()
	i = 0
	flag = 0
	for i in range(len(year) - 1):
		if year[i] == year[i + 1]:
			flag += 1
			break
	if flag == 1:
		prin = int(prin) + 1
		prin = str(prin)
	else:
		break
print(int(prin))


yr = input()
iter = int(yr) + 1
flag = 1
while flag == 1:
	unq = 1
	arr = [0] * 10
	x = list(str(iter))
	for ch in x:
		ch = int(ch)
		if arr[ch] == 0:
			arr[ch] = 1
		else:
			unq = 0
	if unq == 1:
		print(str(iter))
		break
	iter = iter + 1


x = input()
x = int(x)
for i in range(x + 1, 9013):
	vide = ''
	for number in str(i):
		if number not in vide:
			vide += number
	if vide == str(i):
		print(i)
		break


n = input()
num = int(n)
s = list(n)
for i in range(1, 8000):
	S = list(str(num + i))
	if S[0] not in S[1:] and S[1] not in S[2:] and (S[2] != S[3]):
		print(num + i)
		break
	else:
		pass


def isDistinct(y):
	y = str(y)
	s = set()
	s.add(y[0])
	s.add(y[1])
	s.add(y[2])
	s.add(y[3])
	return len(s) == 4
y = int(input())
y += 1
while not isDistinct(y):
	y += 1
print(y)


A = int(input())
A += 1
while A % 10 == A // 10 % 10 or A % 10 == A // 100 % 10 or A % 10 == A // 1000 or (A // 10 % 10 == A // 100 % 10) or (A // 10 % 10 == A // 1000) or (A // 100 % 10 == A // 1000):
	A += 1
print(A)


n = int(input())
for i in range(n + 1, 9013, 1):
	i = str(i)
	c = 1
	for k in range(1, len(i)):
		for j in range(0, k, 1):
			if i[j] == i[k]:
				c = 0
	if c == 1:
		print(i)
		break


x = int(input())
for i in range(x + 1, 9013):
	st = set()
	s = str(i)
	for j in s:
		st.add(int(j))
	if len(st) == 4:
		print(i)
		break


n = int(input())
n += 1
while 1:
	if n >= 1987 and n < 2013:
		print('2013')
		break
	else:
		a = str(n)
		l = list(set(a))
		if len(l) == len(a):
			print(n)
			break
		n += 1


n = int(input())
mini = 0
for i in range(n + 1, 10000):
	l = list(str(i))
	s = set(l)
	if len(l) == len(s):
		print(i)
		break


d = int(input()) + 1
while len(set(str(d))) < 4:
	d += 1
print(d)


y = int(input())
for i in range(y + 1, 9999):
	x = str(i)
	ax = []
	for j in range(len(x)):
		ax += [x[j]]
	ax.sort()
	xis = [ax[0]]
	for k in range(len(ax) - 1):
		for l in range(k, len(xis)):
			if xis[l] != ax[k + 1]:
				xis += [ax[k + 1]]
	if len(xis) == 4:
		break
print(x)


def IsYear(year):
	m = []
	while year != 0:
		if int(year % 10) not in m:
			m.append(int(year % 10))
		else:
			return False
		year = int(year / 10)
	return True
year = int(input())
year += 1
while not IsYear(year):
	year += 1
print(year)


year_intr = input()
year_intr = int(year_intr)
year_distinct = year_intr
while True:
	ok = True
	year_distinct += 1
	year_distinct = str(year_distinct)
	empty = ''
	for piece in year_distinct:
		if len(empty) > 0:
			if piece in empty:
				ok = False
		empty = empty + piece
	if ok:
		break
	year_distinct = int(year_distinct)
print(year_distinct)


yr = input()

def is_beautifull(yr):
	while True:
		yr = str(int(yr) + 1)
		if len(set(yr)) == 4:
			return yr
print(is_beautifull(yr))


t = int(input())
while t < 10000:
	t += 1
	a = t % 10
	b = t // 10 % 10
	c = t // 100 % 10
	d = t // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(t)


def dy(n):
	l = []
	for i in str(int(n) + 1):
		l.append(i)
	if len(set(l)) != 4:
		l = []
		dy(str(int(n) + 1))
	else:
		for i in l:
			print(*str(i), end='')
n = input()
dy(n)


n = int(input())
s = set()
while len(s) != 4:
	s.clear()
	n = n + 1
	n1 = str(n)
	s.add(n1[0])
	s.add(n1[1])
	s.add(n1[2])
	s.add(n1[3])
print(n, end='')


ans = []
a = int(input())
for i in range(a + 1, 10000, 1):
	year = i
	digit = []
	while year > 0:
		digit.append(year % 10)
		year = year // 10
	flag = []
	for j in range(0, 10, 1):
		flag.append(0)
	for j in digit:
		flag[j] = flag[j] + 1
	ok = 1
	for j in range(0, 10, 1):
		if flag[j] > 1:
			ok = 0
	if ok == 1:
		print(i)
		break


g = int(input()) + 1
for g in range(g, 10000):
	if len(set(str(g))) == 4:
		print(g)
		break


year = str(int(input()) + 1)
done = False
while done == False:
	n = len(year) - len(set(year))
	if n > 0:
		year = str(int(year) + 1)
	else:
		print(year)
		done = True


def is_cool(x):
	return len(set(str(x))) == 4
y = int(input())
while True:
	y += 1
	if is_cool(y):
		print(y)
		break


n = int(input())
n = n + 1
while True:
	string = str(n)
	arr = []
	for i in string:
		arr.append(i)
	if len(arr) == len(set(arr)):
		print(n)
		break
	else:
		n = n + 1


n = int(input())
n = n + 1
while 1:
	a = []
	temp = n
	while temp > 0:
		a.append(temp % 10)
		temp = temp // 10
	if len(set(a)) == len(a):
		print(n)
		break
	else:
		n = n + 1


def check(a):
	arr = []
	for i in a:
		arr.append(i)
	if len(arr) == len(list(set(arr))):
		return True
	else:
		return False
a = input()
while True:
	a = str(int(a) + 1)
	if check(a):
		break
print(a)


y = int(input())
y_l = list(str(y))
y_p = set('')
while len(y_p) != 4:
	y += 1
	y_p = set(list(str(y)))
print(y)


n = int(input())
while 1:
	t = True
	n = n + 1
	m = n
	l = [m % 10]
	while m // 10 != 0:
		m = m // 10
		if m % 10 not in l:
			l.append(m % 10)
		else:
			t = False
			break
	if t:
		break
print(n)


def diff(x):
	lst = []
	while x != 0:
		if x % 10 in lst:
			return -1
		else:
			lst.append(x % 10)
		x = x // 10
	return len(lst)

def main():
	n = int(input())
	i = n + 1
	while 1:
		if diff(i) != -1:
			print(i)
			break
		i = i + 1
main()


n = int(input())
for i in range(n + 1, 10000):
	s = str(i)
	f = [0] * 10
	for j in s:
		f[int(j)] += 1
	xx = 1
	for j in range(10):
		if f[j] > 1:
			xx = 0
			break
	if xx == 1:
		print(i)
		exit()
		break


n = int(input()) + 1

def fun(s):
	for i in range(len(s)):
		for j in range(len(s)):
			if i != j and s[i] == s[j]:
				return True
while fun(str(n)):
	n += 1
print(n)


x = input()
flag = 'false'
while flag == 'false':
	x = int(x)
	x = x + 1
	x = str(x)
	if x[0] != x[1]:
		if x[0] != x[2]:
			if x[0] != x[3]:
				if x[1] != x[2]:
					if x[1] != x[3]:
						if x[2] != x[3]:
							flag = 'true'
print(x)


i = int(input()) + 1
while True:
	s = set()
	for j in str(i):
		s.add(j)
	if len(s) == 4:
		print(i)
		break
	i += 1


def fun(num):
	(count, temp, set1) = (0, num, {1, 2, 3})
	set1.clear()
	while temp != 0:
		count += 1
		temp = temp // 10
	temp = num
	while temp != 0:
		set1.add(temp % 10)
		temp = temp // 10
	if len(set1) == count:
		return 1
	else:
		set1.clear()
		return 0
num = int(input())
while True:
	num += 1
	s = fun(num)
	if s == 1:
		print(num)
		break


year = int(input())
for i in range(year + 1, 10000):
	s = str(i)
	one = s[0]
	two = s[1]
	three = s[2]
	four = s[3]
	if one not in two + three + four and two not in one + three + four and (three not in one + two + four) and (four not in one + two + three):
		print(i)
		break


year = input()
for i in range(int(year) + 1, 1000000):
	currentYear = str(i)
	isBeautiful = True
	for i in currentYear:
		count = currentYear.count(i)
		if count > 1:
			isBeautiful = False
	if isBeautiful:
		print(currentYear)
		break


z = input()
z = str(int(z) + 1)
k = 1
while k == 1:
	flag = 0
	w = []
	for i in z:
		if i in w:
			z = str(int(z) + 1)
			flag = 1
			break
		w.append(i)
	if flag == 0:
		k = 0
		break
print(z)


y = int(input())
digits = set()
while True:
	y += 1
	sd = str(y)
	for i in sd:
		digits.add(i)
	if len(digits) == len(sd):
		print(y)
		break
	else:
		digits.clear()


enter_year = int(input())
output_year = str(enter_year + 1)
while len(set(output_year)) != 4:
	output_year = int(output_year)
	output_year += 1
	output_year = str(output_year)
print(output_year)


a = int(input())
a = a + 1

def differentCharac(b):
	if len(str(b)) == len(set(str(b))):
		return True
	else:
		return False
while len(str(a)) != len(set(str(a))):
	a = a + 1
print(a)


a = int(input())

def abd(ast):
	lst = []
	for i in str(ast):
		if i not in lst:
			lst.append(i)
	return len(lst)
b = a + 1
while abd(str(b)) != 4:
	b = b + 1
print(b)


def good(n):
	a = n // 1000
	b = n % 1000 // 100
	c = n % 100 // 10
	d = n % 10
	if a != b and b != c and (c != d) and (a != c) and (a != d) and (b != d):
		return True
	else:
		return False
n = int(input())
while n < 100000:
	n += 1
	if n >= 10000:
		print(10234)
		break
	if good(n):
		print(n)
		break


y = int(input()) + 1

def notdistinct(par):
	par = [par[0], par[1], par[2], par[3]]
	par = set(par)
	return len(par) != 4
while notdistinct(str(y)):
	y += 1
print(y)


n = int(input())
while 1:
	a = []
	for i in range(0, 10):
		a.append(0)
	n += 1
	temp = n
	while temp > 0:
		r = temp % 10
		a[r] += 1
		temp = temp // 10
	f = True
	for i in range(0, 10):
		if a[i] > 1:
			f = False
	if f == True:
		break
print(n)


def contar(a, n, r):
	f = 0
	while r < n:
		t = a.count(a[r])
		f = f + t
		if f > n:
			c = 0
			r = r + 1
		else:
			c = 1
			r = r + 1
	return c
a = input()
r = 0
k = 1
while k > 0:
	a = int(a) + k
	a = str(a)
	n = len(a)
	r = 0
	r1 = contar(a, n, r)
	if r1 == 0:
		k = 1
	elif r1 == 1:
		k = 0
		print(a)


n = int(input())
distinct = False
while distinct == False:
	n += 1
	detect = list()
	check = 0
	for i in str(n):
		if i not in detect:
			detect.append(i)
		elif i in detect:
			check = 1
			break
	if check != 1:
		print(n)
		break


n = int(input())
n = n + 1
p = q = r = s = 0
while p == q or p == r or p == s or (q == r) or (q == s) or (r == s):
	p = n % 10
	q = n // 10 % 10
	r = n // 100 % 10
	s = n // 1000 % 10
	n = n + 1
print(n - 1)


year = int(input())
year += 1
while len(set([x for x in str(year)])) != len(str(year)):
	year += 1
print(year)


n = int(input())
s = set()
while True:
	n = int(n)
	n += 1
	st = str(n)
	if len(st) == len(set(st)):
		print(st)
		break
	else:
		continue


n = int(input())

def check(x):
	st = []
	for i in x:
		if i in st:
			return False
		st.append(i)
	return True
while True:
	n += 1
	if check(str(n)):
		print(n)
		exit(0)


Year = int(input()) + 1

def checkdigits(digits):
	fr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for d in digits:
		fr[d] += 1
	for f in fr:
		if f > 1:
			return False
	return True
while True:
	Digits = []
	for dig in str(Year):
		Digits.append(int(dig))
	if checkdigits(Digits):
		print(str(Year))
		quit()
	else:
		Year += 1


n = int(input())

def is_distinct(t):
	char_x = str(t)
	chars = set()
	for i in char_x:
		if i in chars:
			return False
		chars.add(i)
	return True

def next_distinkt(x):
	while True:
		x += 1
		if is_distinct(x):
			return x
print(next_distinkt(n))


n = int(input())
n += 1
k = n
while True:
	a = [0 for i in range(4)]
	i = 0
	kk = 1
	while k:
		rem = k % 10
		a[i] = rem
		i += 1
		k = k // 10
	for i in range(4):
		for j in range(i + 1, 4):
			if a[i] == a[j]:
				kk = 0
				break
		if kk == 0:
			break
	if kk == 0:
		n += 1
		k = n
		continue
	else:
		print(n)
		break


from collections import Counter
n = int(input())
i = n + 1
while True:
	if len(Counter(str(i))) == 4:
		print(''.join(str(i)))
		break
	i += 1


def unique(x):
	y = list(str(x))
	ans = False
	if len(y) == len(list(set(map(str, y)))):
		ans = True
	else:
		ans = False
	return ans
n = int(input())
if n >= 8976:
	print(9012)
else:
	for i in range(n + 1, 8977):
		if unique(i) == True:
			print(i)
			break


from collections import OrderedDict
year = int(input())
next_year = 0
i = 0
while i <= 9000:
	year = year + 1
	next_year = list(str(year))
	n_y = list(OrderedDict.fromkeys(next_year))
	if len(n_y) == 4:
		print(''.join(n_y))
		break
	i = i + 1


n = input()
c = int(n) + 1
b = list(str(c))
while int(b[0]) == int(b[1]) or int(b[0]) == int(b[2]) or int(b[0]) == int(b[3]) or (int(b[1]) == int(b[2])) or (int(b[1]) == int(b[3])) or (int(b[2]) == int(b[3])):
	c = c + 1
	b = list(str(c))
print(c)


n = int(input()) + 1
while 1:
	s = str(n)
	l = len(s)
	c = 0
	t = ''
	for i in s:
		if i not in t:
			t += i
			c += 1
	if c == l:
		print(s)
		break
	n += 1


def isBeau(n):
	n = list(str(n))
	n.sort()
	return n[0] != n[1] != n[2] != n[3]
y = int(input())
while True:
	y += 1
	if isBeau(y):
		print(y)
		break


y = input()
y1 = int(y)
ny = y1
while True:
	ny = ny + 1
	tny = set(map(int, str(ny)))
	if len(tny) == 4:
		break
print(ny)


a = int(input())
s = []
k1 = set()
k2 = set()
while 1000 <= a:
	s.clear()
	k1.clear()
	k2.clear()
	a = a + 1
	for i in str(a):
		s.append(int(i))
	for i in s:
		if i not in k1:
			k1.add(i)
		else:
			k2.add(i)
	k3 = k1 & k2
	if k3 == set():
		break
	else:
		continue
G = int(''.join((str(i) for i in s)))
print(G)


y = int(input())
x = y
while 1:
	x += 1
	l = str(x)
	l = set(l)
	if len(l) == 4:
		break
	else:
		pass
print(x)


t1 = int(input())
t1 += 1
while len(set(str(t1))) != 4:
	t1 += 1
print(t1)


def beautiful_year(n):
	while 1:
		n = n + 1
		a = n // 1000
		b = n // 100 % 10
		c = n // 10 % 10
		d = n % 10
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			break
	return n

def main():
	n = int(input())
	print(beautiful_year(n))
main()


n = int(input())
for i in range(n + 1, 10000):
	a = [0 for i in range(10)]
	t = i
	while t != 0:
		x = t % 10
		a[x] += 1
		t = t // 10
	bool = 0
	for j in range(10):
		if a[j] > 1:
			bool = 1
			break
	if bool == 0:
		print(i)
		break


s = str(input())
y = int(s)
while True:
	y += 1
	d = []
	is_unique = True
	for yy in str(y):
		is_in = False
		for dd in d:
			if yy == dd:
				is_in = True
				break
		if is_in:
			is_unique = False
			break
		else:
			d += [yy]
	if is_unique:
		print(y)
		break


n = int(input())
n += 1
x1 = n % 10
x2 = n // 10 % 10
x3 = n // 100 % 10
x4 = n // 1000
while x1 == x2 or x1 == x3 or x1 == x4 or (x2 == x3) or (x2 == x4) or (x3 == x4):
	n += 1
	x1 = n % 10
	x2 = n // 10 % 10
	x3 = n // 100 % 10
	x4 = n // 1000
print(n)


y = int(input())
while True:
	y += 1
	ans = str(y)
	if len(ans) == len(set(list(ans))):
		print(ans)
		exit()


inp_year = int(input())
out_year = 1000
if out_year < inp_year:
	out_year = inp_year + 1
for i in range(out_year, 9877):
	s = str(i)
	if len(set(s)) == len(s):
		print(s)
		break


def checkNum(num):
	for i in range(4):
		for j in range(i + 1, 4):
			if num[i] == num[j]:
				return True
	return False
y = int(input()) + 1
while checkNum(str(y)):
	y += 1
print(y)


import sys
import math
import bisect
import re

def solve(n):
	for i in range(n, 10 ** 9):
		s = str(i)
		if len(set(list(s))) == len(s):
			return i
	return -1

def main():
	n = int(input())
	ans = solve(n + 1)
	print(ans)
main()


import re
n = int(input())
n = n + 1
while True:
	x = str(n)
	y = dict()
	for i in x:
		y[i] = y.get(i, 0) + 1
	z = y.values()
	if 2 in z:
		n = n + 1
		continue
	elif 3 in z:
		n = n + 1
		continue
	elif 4 in z:
		n = n + 1
		continue
	else:
		break
print(n)


n = int(input())
for i in range(n + 1, 100000):
	dic = {x: 0 for x in range(10)}
	dic[i // 1000] += 1
	dic[i // 100 % 10] += 1
	dic[i // 10 % 10] += 1
	dic[i % 10] += 1
	flag = 0
	for (key, value) in dic.items():
		if value > 1:
			flag = 1
	if flag == 0:
		print(i)
		break


year = int(input())
year += 1
while True:
	year_s = str(year)
	for digit in year_s:
		if year_s.count(digit) > 1:
			break
	else:
		break
	year += 1
print(int(year_s))


a = int(input())
a += 1
a = list(str(a))
while True:
	if len(set(a)) == 4:
		print(''.join(a))
		break
	else:
		a = int(''.join(a))
		a += 1
		a = list(str(a))


y = input()
a = int(y) + 1
y = str(a)
while y[0] == y[1] or y[1] == y[2] or y[2] == y[3] or (y[0] == y[2]) or (y[0] == y[3]) or (y[1] == y[3]):
	a += 1
	y = str(a)
print(a)


n = int(input())
f = 0
while f == 0:
	x = []
	n += 1
	s = str(n)
	for c in s:
		if c in x:
			break
		else:
			x.append(c)
	if len(x) == len(s):
		f = 1
print(n)


def check(data):
	for i in range(3):
		if data[i] in data[i + 1:]:
			return False
	return True
year = int(input())
found = False
while not found:
	year += 1
	found = check(str(year))
print(year)


year = int(input()) + 1
x = True
while x:
	str_year = str(year)
	if len(set(str_year)) == len(str_year):
		print(year)
		break
	else:
		year += 1


n = int(input())
while 1 > 0:
	x = str(n + 1)
	b = []
	for i in list(x):
		if i not in b:
			b.append(i)
	if len(b) == len(x):
		print(x)
		break
	else:
		n += 1


def distinctYear(num):
	s = str(num)
	for i in range(len(s)):
		if s.count(s[i]) > 1:
			return 5
	return 10
n = int(input())
n += 1
while distinctYear(n) != 10:
	n += 1
print(n)


def stringToList(n):
	return [i for i in n]
year = str(int(input()) + 1)
while len(stringToList(year)) != len(set(stringToList(year))):
	year = str(int(year) + 1)
print(year)


y = int(input())
verif = False
n = y + 1
while verif == False:
	ch = str(n)
	e = set(ch)
	if len(e) == len(ch):
		verif = True
	else:
		n += 1
print(n)


a = int(input())
k = 0
c = []
for i in range(a + 1, 9015):
	for g in range(4):
		b = str(i)
		if not b[g] in c:
			k += 1
			c.append(b[g])
	if k == 4:
		print(i)
		break
	else:
		k = 0
		c = []


import math, sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def diff(n):
	ar = [0] * 10
	while n > 0:
		digit = math.floor(n % 10)
		if ar[digit]:
			return 0
		ar[digit] = 1
		n = int(n / 10)
	return 1
y = inp() + 1
while not diff(y):
	y += 1
print(y)


n = int(input())
m = str(n + 1)

def f(a):
	b = ''
	for i in a:
		if i not in b:
			b += i
	if b == a:
		return True
	else:
		return False
if f(m) == True:
	print(m)
else:
	while f(m) == False:
		m = str(int(m) + 1)
	print(m)


a = int(input())
a += 1
while True:
	b = a % 10
	c = a // 10 % 10
	d = a // 100 % 10
	e = a // 1000
	if b == c or b == d or b == e or (c == d) or (c == e) or (d == e):
		a += 1
	else:
		print(a)
		break


n = input()
l = list(n)
for i in range(int(n) + 1, 9013):
	s = str(i)
	if s[0] != s[1] and s[1] != s[2] and (s[2] != s[3]) and (s[0] != s[3]) and (s[0] != s[2]) and (s[1] != s[3]):
		print(s)
		break


def frequencyDigits(n, d):
	c = 0
	while n > 0:
		if n % 10 == d:
			c += 1
		n = int(n / 10)
	return c

def checkNumber(n):
	c = 0
	for i in range(10):
		if frequencyDigits(n, i) > 1:
			return 0
	return 1
numero = int(input())
numero += 1
flag = 1
while flag:
	if checkNumber(numero):
		flag = 0
	else:
		numero += 1
print(numero)


a = int(input())
b = a + 1
while b < 1000000:
	c = b // 1000
	d = (b - c * 1000) // 100
	e = (b - c * 1000 - d * 100) // 10
	f = b - c * 1000 - d * 100 - e * 10
	if c == d or c == e or c == f or (d == e) or (d == f) or (e == f):
		b += 1
	else:
		print(b)
		exit()


n = int(input())
t = n + 1
while 1 > 0:
	list1 = list(str(t))
	list2 = set(list1)
	if len(list1) == len(list2):
		print(t)
		break
	else:
		t += 1


def check_diff_year(year):
	u = year % 10
	d = int(year % 100 / 10)
	c = int(year % 1000 / 100)
	t = int(year / 1000)
	if u == d or u == c or u == t or (d == c) or (d == t) or (c == t):
		return True
	else:
		return False
y = int(input())
y = y + 1
while check_diff_year(y):
	y = y + 1
print(y)


def checkDiff(ls):
	arr = []
	ls = str(ls)
	for i in ls:
		if i not in arr:
			arr.append(i)
		else:
			return 0
	return 1
nm = int(input())
while True:
	nm += 1
	if checkDiff(nm):
		print(nm)
		break


y = int(input())
x = str(y + 1)

def tryout(a):
	a = str(a)
	lista = []
	for letra in range(len(a)):
		if a[letra] not in lista:
			lista.append(a[letra])
	if len(lista) == 4:
		return True
	else:
		return False
while tryout(x) == False:
	x = str(int(x) + 1)
print(x)


LIMIT = 9100

def check_distinct_digit(number: int) -> bool:
	has_distinct_digit = True
	digit_visited = set()
	while number:
		if number % 10 in digit_visited:
			has_distinct_digit = False
			break
		digit_visited.add(number % 10)
		number //= 10
	return has_distinct_digit

def compute_distinct_year(year: int) -> int:
	for yr in range(year + 1, LIMIT):
		if check_distinct_digit(yr):
			distinct_year = yr
			break
	return distinct_year

def main():
	print(compute_distinct_year(int(input().strip())))
main()


n = int(input())
while True:
	l = []
	n += 1
	num = n
	x = num % 10
	l.append(x)
	num = int(num / 10)
	y = num % 10
	l.append(y)
	num = int(num / 10)
	z = num % 10
	l.append(z)
	num = int(num / 10)
	k = num % 10
	l.append(k)
	b_l = list(dict.fromkeys(l))
	if len(b_l) == 4:
		print(n)
		break


y1 = int(input())
j = k = 0
c = 1
a = [0, 0, 0, 0]
while c != 0:
	i = 0
	y1 = y1 + 1
	y = y1
	while y > 0 and y < 10000:
		d = y % 10
		a[i] = d
		i += 1
		y //= 10
	c = 0
	for i in range(1, 4):
		for j in range(0, i):
			if a[i] == a[j]:
				c += 1
				break
		if c > 0:
			break
for t in range(3, -1, -1):
	print(a[t], end='')


y = int(input())
z = str(y + 1)
while len(set(str(z))) < 4:
	z = int(z) + 1
print(z)


a = int(input()) + 1
while True:
	if str(a)[0] not in str(a)[1:] and str(a)[1] not in str(a)[2:] and (str(a)[2] not in str(a)[3]):
		print(a)
		break
	else:
		a += 1


x = int(input())
y = 0
while y != 4:
	x += 1
	y = len(set(str(x)))
print(x)


def years(year):
	a = 0
	ls = [year[0], year[1], year[2], year[3]]
	ls.sort()
	if ls[0] < ls[1] and ls[1] < ls[2] and (ls[2] < ls[3]):
		a = a + 1
	return bool(a == 1)
year = str(1 + int(input()))
while not years(year):
	year = str(int(year) + 1)
print(year)


n = int(input())
i = n + 1
while True:
	l = len(set(list(str(i))))
	if l > 3:
		print(i)
		break
	i += 1


def by(yrs):
	while True:
		yrs = str(int(yrs) + 1)
		if len(set(yrs)) == 4:
			return yrs
n = input()
print(by(n))


year = input()
for num in range(int(year) + 1, 10001):
	yearString = str(num)
	if len(set(yearString)) == 4:
		print(yearString)
		break


y = str(int(input()) + 1)
r = True
while r:
	distinct = True
	for i in range(len(y)):
		for j in range(i + 1, len(y)):
			if y[i] == y[j]:
				distinct = False
	if distinct:
		print(y)
		break
	else:
		y = str(int(y) + 1)


print(next((x for x in range(int(input()) + 1, 9999) if len(set(str(x))) == 4)))


def ans(arr):
	ans = arr + 1
	while len(set(str(ans))) != 4:
		ans += 1
	return ans
t = int(input())
print(ans(t))


n = int(input())
isPerfect = False
while isPerfect == False:
	n += 1
	aux = str(n)
	if aux[0] != aux[1] and aux[0] != aux[2] and (aux[0] != aux[3]) and (aux[1] != aux[2]) and (aux[1] != aux[3]) and (aux[2] != aux[3]):
		isPerfect = True
print(n)


def year():
	d = int(x) + 1
	f = set(str(d))
	while len(f) <= 4:
		if len(f) == 4:
			return d
		else:
			d = int(d) + 1
			f = set(str(d))
x = input()
print(year())


num = int(input()) + 1
while len(set(str(num))) < 4:
	num += 1
print(num)


inp = int(input())
lst = list()
fnl_lst = list()
x = 1
while True:
	year = inp + x
	x = x + 1
	s = str(year)
	if s not in lst:
		lst.append(s)
	if year == 9019:
		break
for a in lst:
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		fnl_lst.append(a)
fnl_lst.sort()
req_year = int(fnl_lst[0])
print(req_year)


import math
import os
import sys
import re
import itertools
import functools
import operator
for i in range(int(input()) + 1, 10000):
	if len(set(str(i))) == 4:
		print(i)
		quit()


n = int(input())
a = []
if n in range(1987, 2013):
	print('2013')
else:
	flag = 1
	while flag != 0:
		flag = 0
		n = n + 1
		i = n
		a.clear()
		while i > 0:
			v = i % 10
			if v in a:
				flag = 1
				break
			a.append(v)
			i //= 10
		if flag == 0:
			if n > 1987 and n < 2013:
				print(2013)
			else:
				print(n)


s = int(input())
y = []
while len(y) != 4:
	s = s + 1
	for i in str(s):
		if int(i) not in y:
			y.append(int(i))
			if len(y) == 4:
				print(s)
				break
		else:
			y.clear()
			break


year = int(input())
while True:
	year += 1
	d1 = year // 1000
	d2 = year // 100 % 10
	d3 = year // 10 % 10
	d4 = year % 10
	if d1 != d2 and d1 != d3 and (d1 != d4) and (d2 != d3) and (d2 != d4) and (d3 != d4):
		break
print(year)


y = int(input())
i = y + 1
while i > y:
	a = str(i)
	a = list(a)
	d = {}
	for j in range(len(a)):
		if a[j] in d:
			break
		else:
			d[a[j]] = 1
	if len(d) == len(a):
		print(i)
		break
	else:
		i += 1


a = int(input())
nian = str(a + 1)
while nian.count(nian[0]) > 1 or nian.count(nian[2]) > 1 or nian.count(nian[2]) > 1 or (nian.count(nian[3]) > 1):
	nian = str(int(nian) + 1)
print(nian)


a = int(input())
while 1:
	a += 1
	b = set(map(str, str(a)))
	if len(b) == 4:
		print(a)
		break


year = int(input())
i = year + 1
while i > year:
	yea = str(i)
	num = []
	for i in range(4):
		p = yea.count(yea[i])
		num.append(p)
	j = 0
	for i in num:
		if i == 1:
			j = j + 1
	if j == 4:
		print(int(yea))
		break
	i = int(yea) + 1


def isdistinct(n):
	l = []
	while n:
		n1 = n % 10
		if n1 in l:
			return False
		l.append(n1)
		n = int(n / 10)
	return True
n = int(input()) + 1
while 1:
	if isdistinct(n) == True:
		print(n)
		break
	n += 1


year = int(input())
counter = 0
while counter != 4:
	year += 1
	year = str(year)
	counter = 0
	for i in range(10):
		if str(i) in year:
			counter += 1
	year = int(year)
print(year)


inn = int(input())
while inn != None:
	check = False
	data = []
	inn += 1
	a = str(inn)
	for i in a:
		for j in data:
			if i == j:
				check = True
				break
		if check == True:
			break
		data.append(i)
	if check == False:
		break
print(inn)


n = str(int(input()) + 1)
(i, j, k, l) = (int(n[0]), int(n[1]), int(n[2]), int(n[3]))
while i < 10:
	while j < 10:
		while k < 10:
			while l < 10:
				if l not in [i, j, k] and k not in [i, j] and (i != j):
					print(i * 1000 + j * 100 + k * 10 + l)
					exit()
				l += 1
			k += 1
			l = 0
		j += 1
		k = 0
	i += 1
	j = 0


year = input()
year = str(int(year) + 1)
length = len(year)
while not len(set(year)) == length:
	year = str(int(year) + 1)
print(year)


def disdig(k):
	k = str(k)
	if k[0] not in k[1:] and k[1] not in k[2:] and (k[2] not in k[3]):
		return True
	else:
		return False
n = int(input())
while disdig(n + 1) != True:
	n += 1
print(n + 1)


n = int(input())
n += 1
a = list(str(n))
a1 = set()
for i in a:
	a1.add(int(i))
while len(a1) != 4:
	a1 = set()
	n += 1
	a = list(str(n))
	for i in a:
		a1.add(int(i))
print(n)


y = int(input())

def check(a):
	l = []
	while a != 0:
		x = a % 10
		l.append(x)
		a = a // 10
	for i in l:
		n = l.count(i)
		if n > 1:
			return False
	return True
while y < 10000:
	y += 1
	if check(y):
		break
print(y)


n = int(input())
m = n + 1
while 1 > 0:
	t = list(str(m))
	s = set(str(m))
	if len(s) == len(t):
		print(m)
		break
	else:
		m = m + 1


a = input()
a = int(a)
a += 1
a = str(a)
b = int(a)
flag = True

def check(a):
	count = 0
	for i in range(len(a)):
		for j in range(len(a)):
			if a[i] == a[j]:
				count += 1
		if count > 1:
			return False
		count = 0
	return True
while flag == True:
	if check(a) == True:
		print(a)
		flag = False
		break
	else:
		b += 1
		a = str(b)


INF = 999999
by = int(input())
for i in range(by + 1, INF):
	byl = [int(i) for i in str(i)]
	if len(byl) == len(set(byl)):
		print(i)
		break


y = int(input())
while True:
	l = list(str(y + 1))
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
		print(int(''.join(l)))
		break
	y = int(''.join(l))


def checkDistinct(n):
	t = []
	for i in range(4):
		t.append(n % 10)
		n //= 10
	for i in range(2):
		(t[i], t[3 - i]) = (t[3 - i], t[i])
	for i in range(4):
		for j in range(i + 1, 4):
			if t[i] == t[j]:
				return 0
	return t
y = int(input())
num = 0
for i in range(1, 150):
	x = y + i
	check = checkDistinct(x)
	if check != 0:
		for i in range(4):
			num *= 10
			num += check[i]
		print(num)
		break


n = int(input())
while True:
	n += 1
	m = n
	d1 = m % 10
	m = m // 10
	d2 = m % 10
	m = m // 10
	d3 = m % 10
	m = m // 10
	d4 = m % 10
	if len(set((d1, d2, d3, d4))) == 4:
		break
print(n)


hren = 0
year = int(input())
while hren == 0:
	year += 1
	counter = 0
	yearx = str(year)
	digits = list()
	for i in range(4):
		if digits.count(yearx[i]) == 0:
			digits.append(yearx[i])
	if len(digits) == 4:
		print(year)
		hren = 25


n = int(input())
m = n + 1
while len(list(dict.fromkeys(list(str(m))))) != 4:
	m = m + 1
print(m)


def diff_digits(number):
	number_list = list(str(number))
	my_set = set(number_list)
	if len(number_list) > len(my_set):
		return False
	else:
		return True
year = int(input())
year += 1
while True:
	if diff_digits(year):
		print(year)
		exit()
	else:
		year += 1


def checkvalid(year):
	for c in str(year):
		if str(year).count(c) > 1:
			return False
	return True
year = int(input()) + 1
valid = False
while True:
	valid = checkvalid(year)
	if valid:
		break
	else:
		year += 1
print(year)


y = int(input())
achou = 0
y += 1
while not achou:
	digitos = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
	ano = [str(i) for i in str(y)]
	for i in range(len(ano)):
		if digitos[ano[i]] == 1:
			y += 1
			break
		else:
			digitos[ano[i]] = 1
			if i == 3:
				achou = 1
				break
print(y)


n = int(input())
n = n + 1
l = []
unique_l = []
while len(unique_l) != 4:
	unique_l.clear()
	l.clear()
	m = n
	i = 0
	for i in range(4):
		k = m % 10
		l.append(k)
		m = int(m / 10)
	l_set = set(l)
	unique_l = list(l_set)
	if len(unique_l) != 4:
		n = n + 1
print(n)


y = int(input())
y = y + 1

def f(y):
	s = str(y)
	a = []
	for i in s:
		a.append(i)
	se = set(a)
	if len(se) == len(a):
		print(y)
	else:
		f(y + 1)
f(y)


a = int(input()) + 1
b = []
b.extend(str(a))
while len(set(b)) != 4:
	b.clear()
	a = a + 1
	b.extend(str(a))
else:
	print(a)


n = input()
tmp = int(n)
count = 1
while 1:
	(n, tmp) = (str(tmp + 1), tmp + 1)
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				count = 0
				break
	if count:
		break
	count = 1
print(tmp)


def diffs(n):
	t = str(n)
	for j in range(len(t) - 1):
		if t[j] in t[j + 1:]:
			return False
	return True
y = int(input())
n = y
good = False
while not good:
	n += 1
	good = diffs(n)
print(n)


yearnow = int(input())
yearnow += 1
while len(set(str(yearnow))) != 4:
	yearnow += 1
print(yearnow)


a = int(input())
while 1 == 1:
	a += 1
	t = a // 1000
	h = a // 100 % 10
	s = a // 10 % 10
	g = a % 10
	if t != h and t != s and (t != g) and (h != s) and (h != g) and (s != g):
		print(a)
		break


from collections import Counter
n = int(input())
for i in range(n + 1, 9013):
	j = str(i)
	freq = Counter(j)
	if len(freq) == len(j):
		print(int(j))
		break


n = int(input())
n += 1
c = 0
while c == 0:
	b = []
	m = n
	for i in range(3 + 1):
		b.append(m % 10)
		m = int((m - m % 10) / 10)
	if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
		c = 1
	else:
		n += 1
print(n)


n = int(input())
while 1:
	n += 1
	x = str(n)
	count1 = 0
	for i in x:
		if x.count(i) == 1:
			count1 += 1
	if count1 == 4:
		break
print(n)


year = int(input())
for i in range(year + 1, 9100):
	i = str(i)
	if i[0] != i[1] and i[2] != i[3] and (i[1] != i[3]) and (i[0] != i[2]) and (i[1] != i[2]) and (i[0] != i[3]):
		print(i)
		break


num = int(input())
a = num + 1
while True:
	list = []
	num = 0
	for i in str(a):
		list.append(i)
	for j in list:
		if list.count(j) > 1:
			num += 1
		else:
			num += 0
	if num == 0:
		print(a)
		exit(0)
	else:
		a += 1
		continue


year = input()
n = 0
while True:
	year = str(int(year) + 1)
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]) and (year[1] != year[2]) and (year[1] != year[3]) and (year[2] != year[3]):
		print(year)
		break
	else:
		continue


year = int(input())
while 1:
	year = year + 1
	val = str(year)
	if len(set(val)) == len(val):
		print(val)
		break


[print(i) or exit() for i in range(int(input()) + 1, 10000) if len(set(str(i))) == len(str(i))]


i = int(input())
j = i + 1
while j < 9999:
	satu = j % 10
	puluh = j // 10 % 10
	ratus = j // 100 % 10
	ribu = j // 1000 % 10
	j += 1
	if satu != puluh and satu != ratus and (satu != ribu) and (puluh != ratus) and (puluh != ribu) and (ratus != ribu):
		print(str(ribu) + str(ratus) + str(puluh) + str(satu))
		break


import sys
sy = input()
iy = int(sy)
iy += 1
sy = str(iy)
d = [False] * 10
while True:
	find = True
	for i in range(len(sy)):
		if d[int(sy[i])] is False:
			d[int(sy[i])] = True
		else:
			find = False
			iy += 1
			sy = str(iy)
			d = [False] * 10
			break
	if find:
		print(sy)
		sys.exit(0)


n = int(input())
for i in range(n + 1, 100000):
	num = i
	a = [0] * 10
	while num:
		if a[num % 10] == 1:
			break
		a[num % 10] = 1
		num = int(num / 10)
	if num == 0:
		print(i)
		break


y = input()
while True:
	answer = 1
	digit = {}
	y = str(int(y) + 1)
	for i in y:
		if i in digit:
			answer = 0
		else:
			digit[i] = 1
	if answer == 1:
		break
print(y)


def isDistinct(n):
	digits = [False] * 10
	for x in str(n):
		if digits[int(x)]:
			return False
		digits[int(x)] = True
	return True

def nextDistinct(yr):
	yr += 1
	while not isDistinct(yr):
		yr += 1
	return yr
n = int(input())
print(nextDistinct(n))


year = int(input())
for i in range(year + 1, 9013):
	str1 = str(i)
	if str1[0] != str1[1] and str1[1] != str1[2] and (str1[2] != str1[3]) and (str1[0] != str1[2]) and (str1[0] != str1[3]) and (str1[1] != str1[3]):
		print(str1)
		break


n = int(input())
isUnique = False
while not isUnique:
	n += 1
	digits = [int(x) for x in str(n)]
	digits.sort()
	isUnique = True
	prev = digits[0]
	for i in digits[1:]:
		if i == prev:
			isUnique = False
		prev = i
print(n)


i = int(input())
while i > 0:
	i += 1
	cc = str(i)
	if cc[0] == cc[1] or cc[0] == cc[2] or cc[0] == cc[3] or (cc[1] == cc[2]) or (cc[1] == cc[3]) or (cc[2] == cc[3]):
		continue
	else:
		print(i)
		break


q = int(input())
n = q + 1
d1 = n % 10
d2 = n % 10000 // 1000
d3 = n % 100 // 10
d4 = n % 1000 // 100
b = []
if d1 not in b:
	b.append(d1)
if d2 not in b:
	b.append(d2)
if d4 not in b:
	b.append(d4)
if d3 not in b:
	b.append(d3)
while len(b) < 4:
	n += 1
	d1 = n % 10
	d2 = n % 10000 // 1000
	d3 = n % 100 // 10
	d4 = n % 1000 // 100
	b = []
	if d1 not in b:
		b.append(d1)
	if d2 not in b:
		b.append(d2)
	if d4 not in b:
		b.append(d4)
	if d3 not in b:
		b.append(d3)
print(n)


import itertools as it
years = list(map(lambda p: ''.join(p), it.permutations('0123456789', 4)))
inp = int(input())
print(list(filter(lambda x: int(x) > inp, years))[0])


year = int(input())
year += 1
check = True
while check:
	if len(set(str(year))) == len(str(year)):
		check = False
	else:
		year += 1
print(year)


a = int(input())
a = a + 1
while a:
	s = len(set(list(str(a))))
	l = len(list(str(a)))
	if s == l:
		ans = a
		break
	a += 1
print(ans)


y = input()
x = int(y)
for i in range(x + 1, 9999):
	y = str(i)
	if y[0] != y[1] and y[0] != y[2] and (y[0] != y[3]) and (y[1] != y[2]) and (y[1] != y[3]) and (y[2] != y[3]):
		print(i)
		break


y = int(input())
flag = True
while flag == True:
	y += 1
	yl = [x for x in str(y)]
	if yl[0] != yl[1] and yl[0] != yl[2] and (yl[0] != yl[3]):
		if yl[1] != yl[2] and yl[1] != yl[3]:
			if yl[2] != yl[3]:
				flag = False
	y = int(''.join(yl))
print(y)


def distinct(n):
	ni = n
	ns = str(n)
	(n1, ni) = (str(ni % 10), ni // 10)
	(n2, ni) = (str(ni % 10), ni // 10)
	(n3, ni) = (str(ni % 10), ni // 10)
	n4 = str(ni)
	if ns.count(n1) == 1 and ns.count(n2) == 1 and (ns.count(n3) == 1) and (ns.count(n4) == 1):
		return 1
	else:
		return 0
a = int(input().strip())
a += 1
while distinct(a) == 0:
	a += 1
print(a)


def isDist(year):
	i = 0
	while i < len(year):
		j = i + 1
		while j < len(year):
			if year[i] == year[j]:
				return False
			j += 1
		i += 1
	return True
crash = input()
val = int(crash)
if val > 9000 or val < 1000:
	print('Error')
else:
	val += 1
	crash = str(val)
	while not isDist(crash) and (val <= 9000 or val >= 1000):
		val += 1
		crash = str(val)
	print(crash)


a = int(input())
while True:
	a += 1
	p = list(str(a))
	p.sort()
	answer = 0
	for i in range(3):
		if p[i] == p[i + 1]:
			answer = 1
	if answer == 0:
		print(a)
		break


def main():
	y = int(input())
	while True:
		y += 1
		sy = str(y)
		if len(sy) == len(set(sy)):
			print(y)
			return
main()


n = int(input())
for i in range(n + 1, 9013):
	first = i // 1000
	second = i // 100
	second = second % 10
	third = i // 10
	third = third % 10
	fourth = i % 1000
	fourth = fourth % 100
	fourth = fourth % 10
	if first != second and first != third and (first != fourth) and (second != third) and (second != fourth) and (third != fourth):
		break
print(first * 1000 + second * 100 + third * 10 + fourth)


y = str(input())
y = int(y) + 1
for i in range(1000):
	y = str(y)
	if y[0] != y[1] and y[1] != y[2] and (y[2] != y[3]) and (y[0] != y[2]) and (y[0] != y[3]) and (y[1] != y[3]):
		print(y)
		break
	y = int(y) + 1


def f(y):
	d = {}
	while y > 0:
		r = y % 10
		if r not in d:
			d[r] = 1
		else:
			d[r] += 1
		y = y // 10
	if len(d) == 4:
		return 1
	else:
		return 0
y = int(input())
an = 0
while an != 1:
	y += 1
	an = f(y)
print(y)


n = int(input())
for i in range(n + 1, 20000):
	j = str(i)
	a = len(j)
	b = set(j)
	if a == len(b):
		print(j)
		break


def unique(year):
	for i in range(year + 1, 999999 // 2):
		if len(set(str(i))) == 4:
			print(i)
			break
unique(int(input()))


y = input()
list = []
for i in range(int(y) + 1, 9013):
	for d in str(i):
		list.append(d)
	if list[0] == list[1] or list[0] == list[2] or list[0] == list[3]:
		list.clear()
		continue
	elif list[1] == list[2] or list[1] == list[3]:
		list.clear()
		continue
	elif list[2] == list[3]:
		list.clear()
		continue
	else:
		y = i
		break
print(y)


n = int(input())
for i in range(n + 1, 9100):
	dt = {}
	num = str(i)
	for j in range(len(num)):
		if num[j] in dt:
			dt[num[j]] += 1
		else:
			dt[num[j]] = 1
	if len(dt) == 4:
		print(i)
		break


y = int(input())
y += 1
lst = list(str(y))
while lst[0] == lst[1] or lst[0] == lst[2] or lst[1] == lst[2] or (lst[2] == lst[3]) or (lst[0] == lst[3]) or (lst[1] == lst[3]):
	y += 1
	lst = list(str(y))
else:
	print(y)


n = str(int(input()) + 1)
pole = list(n)
pom = len(pole)
pom_2 = 0

def unique(n, pole, pom, pom_2):
	for i in range(pom):
		for j in range(pom):
			if pole[j] == pole[i] and j != i:
				pom_2 += 1
				break
	if pom_2 == 0:
		print(n)
	if pom_2 > 0:
		pom_2 = 0
		n = str(int(n) + 1)
		pole = list(n)
		pom = len(pole)
		unique(n, pole, pom, pom_2)
unique(n, pole, pom, pom_2)


n = int(input())
d = n + 1
while True:
	x = 0
	m = str(d)
	for i in range(len(m)):
		for j in range(i + 1, len(m)):
			if m[i] == m[j]:
				x += 1
				break
	if x != 0:
		d += 1
	else:
		print(d)
		break


import sys, math

def cheak_distrinct(year):
	for i in year:
		if year.count(i) > 1:
			return 0
	else:
		return 1
year = int(sys.stdin.readline())
while True:
	year += 1
	year_str = str(year)
	if cheak_distrinct(year_str):
		print(year)
		break


n = int(input())

def check(n):
	l = []
	s = str(n)
	for i in range(4):
		if s[i] in l:
			return False
		l.append(s[i])
	return True
while True:
	n = n + 1
	if check(n):
		break
print(n)


def has_distinct_digits(num):
	judge = True
	digits = []
	for c in str(num):
		if int(c) in digits:
			judge = False
			break
		else:
			digits.append(int(c))
	return judge
year = int(input()) + 1
while True:
	if has_distinct_digits(year):
		print(year)
		break
	else:
		year += 1


s = int(input())
while True:
	s += 1
	d = str(s)
	if len(d) == len(set(d)):
		print(s)
		break


def func(n):
	while True:
		n += 1
		s = str(n)
		se = set()
		for char in s:
			se.add(char)
		if len(se) == len(s):
			break
	return n
n = int(input())
print(func(n))


x = input()
a = 0
for i in range(int(x) + 1, int(x) + 1000):
	y = list(str(i))
	for m in y:
		for n in y:
			if m == n:
				a += 1
	if a == len(x):
		print(i)
		exit()
	a = 0


year = int(input())
while True:
	year_found = True
	year += 1
	for i in str(year):
		if i in str(year)[str(year).index(i) + 1:]:
			year_found = False
			break
	if year_found:
		print(year)
		break


iny = int(input())

def distinct(a):
	stack = []
	for i in a:
		if i not in stack:
			stack.append(i)
	return len(stack)
while True:
	iny += 1
	k = distinct(str(iny))
	if k == len(str(iny)):
		print(iny)
		break


import sys
year = sys.stdin.readline()
for i in range(int(year) + 1, 9013):
	if len(set(str(i))) == 4:
		print(i)
		break


n = int(input())
n = n + 1
while n:
	lst = []
	for i in str(n):
		lst.append(i)
	if lst[0] != lst[1] and lst[0] != lst[2] and (lst[0] != lst[3]) and (lst[1] != lst[2]) and (lst[1] != lst[3]) and (lst[2] != lst[3]):
		print(''.join(lst))
		break
	else:
		n = n + 1


w = int(input()) + 1
a = [int(x) for x in str(w)]
b = set((int(x) for x in str(w)))
w1 = len(a)
w2 = len(b)
while w1 != w2:
	w += 1
	a = [int(x) for x in str(w)]
	b = set((int(x) for x in str(w)))
	w1 = len(a)
	w2 = len(b)
print(w)


def dgt(n):
	a = int(n % 10)
	b = int(n / 10) % 10
	c = int(n / 100) % 10
	d = int(n / 1000) % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return 1
	else:
		return 0
n = int(input())
for i in range(n + 1, 10000):
	a = dgt(i)
	if a == 1:
		print(i)
		break


n = int(input()) + 1
while True:
	m = str(n)
	o = set(m)
	if len(o) == len(m):
		print(n)
		break
	n += 1


y = int(input(''))
y += 1
while y < 9500:
	a = str(y)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		print(y)
		break
	y += 1


y = int(input())
for x in range(y + 1, 10000):
	if len({a for a in str(x)}) == 4:
		print(x)
		break


def nice(x):
	f = 1
	a1 = x % 10
	a2 = x % 100 // 10
	a3 = x // 100 % 10
	a4 = x // 1000
	if a1 == a2 or a1 == a3 or a1 == a4:
		f = 0
	if a2 == a3 or a2 == a4:
		f = 0
	if a3 == a4:
		f = 0
	return f
n = int(input())
while 1:
	n += 1
	if nice(n):
		print(n)
		break


try:
	y = input()
	t = str(int(y) + 1)
	while len(set(list(t))) < len(y):
		t = str(int(t) + 1)
	print(t)
except:
	pass


y = int(input())
i = 0
while True:
	y = y + 1
	if len(list(set(str(y)))) >= 4:
		print(str(y))
		break
	else:
		continue


test = int(input())
res = 0
for y in range(test + 1, 10000):
	year = str(y)
	n = len(year)
	for i in range(n - 1):
		sum = 0
		for j in range(i + 1, n):
			if year[i] == year[j]:
				sum += 1
		if sum > 0:
			break
	if sum == 0:
		res = year
		break
print(res)


def f(x):
	y = len(set(list(str(x))))
	return y
x = int(input()) + 1
while f(x) < 4:
	x += 1
print(x)


n = int(input())
while True:
	n = str(int(n) + 1)
	a = []
	for i in n:
		a.append(i)
	t = 0
	while len(a) != 0:
		s = a[0]
		t = t + 1
		while s in a:
			a.remove(s)
	if t == len(n):
		print(n)
		break


year = int(input())
while True:
	year += 1
	year_str = str(year)
	first = year_str.count(year_str[0])
	second = year_str.count(year_str[1])
	third = year_str.count(year_str[2])
	fourth = year_str.count(year_str[3])
	if first == second == third == fourth == 1:
		print(year)
		break


year = int(input()) + 1
while 1:
	f = 0
	n = year
	lis = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while n:
		i = n % 10
		lis[i] += 1
		n = n // 10
	for i in lis:
		if i != 0 and i != 1:
			f = 1
	if f == 0:
		print(year)
		break
	year += 1


t = int(input())
t += 1
s = str(t)
l = set(s)
while len(s) != len(l):
	t += 1
	s = str(t)
	l = set(s)
print(t)


year = int(input())
result = 0
for n in range(year + 1, 10000):
	years = str(n)
	if not years[0] in years[1:] and (not years[1] in years[2:]) and (years[2] != years[3]):
		result = n
		break
print(result)


num = int(input())
a = list(range(1000, 9100))
b = list()
for i in a:
	for (a, s, w, e) in str(i).split(' '):
		if a != s and a != w and (a != e) and (s != w) and (s != e) and (w != e):
			c = f'{a}{s}{w}{e}'
			b.append(int(c))
b.append(num)
sorted_list = sorted(b)
if sorted_list[sorted_list.index(num)] != sorted_list[sorted_list.index(num) + 1]:
	print(sorted_list[sorted_list.index(num) + 1])
else:
	print(sorted_list[sorted_list.index(num) + 2])


def is_unique(n):
	str1 = str(n)
	u = 0
	for i in range(0, len(str1), 1):
		for j in range(0, len(str1), 1):
			if i == j:
				continue
			elif str1[i] == str1[j]:
				return False
	return True
year = int(input()) + 1
while is_unique(year) == False:
	year += 1
print(year)


num = int(input())
for x in range(num + 1, 9999):
	years = list(map(int, str(x)))
	if all(map(lambda x: years.count(x) == 1, years)):
		year = x
		break
print(x)


def isB(s):
	for i in s:
		if s.find(i) != s.rfind(i):
			return False
	return True
y = int(input())
while True:
	y += 1
	if isB(str(y)):
		break
print(y)


def different(el):
	el = str(el)
	ar = set()
	for i in range(len(el)):
		if el[i] in ar:
			return False
		ar.add(el[i])
	return True
el = int(input())
el = el + 1
while True:
	if different(el):
		print(el)
		break
	else:
		el = el + 1


n = input()
for i in range(int(n) + 1, 10000):
	d = list(str(i))
	ans = True
	for j in range(4):
		p = d[j]
		d[j] = 'z'
		if p in d:
			ans = False
		d[j] = p
	if ans is True:
		print(str(i))
		break


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
number = int(f_input()) + 1
while len(set(str(number))) < 4:
	number += 1
f_print(str(number))


n = input()
n = int(n) + 1
while True:
	n = str(n)
	count = 0
	dict = {}
	for i in n:
		if i in dict:
			dict[i] += 1
		else:
			dict[i] = 1
	for (i, j) in dict.items():
		if j == 1:
			count += 1
		else:
			n = int(n) + 1
			break
	if count == 4:
		print(n)
		break


n = int(input())
y = str(n + 1)

def btf_year(y=y):
	while True:
		v = True
		for i in range(len(y)):
			for j in range(i + 1, len(y)):
				if y[i] == y[j]:
					v = False
					y = str(int(y) + 1)
				if v:
					if j == 3 and i == 2:
						return y
print(btf_year())


a = int(input())
for i in range(a + 1, 10000):
	stri = str(i)
	if len(stri) == len(set(stri)):
		print(i)
		break


def main():
	n = int(input()) + 1
	while len(set(str(n))) != len(str(n)):
		n += 1
	print(n)
main()


basey = input()
numy = eval(basey) + 1
set1 = set(str(numy))
while len(set1) < 4:
	numy += 1
	set1.clear()
	set1 = set(str(numy))
print(numy)


x = int(input()) + 1
while True:
	a = [str(y) for y in str(x)]
	if len(set(a)) == len(str(x)):
		print(x)
		break
	else:
		x += 1
		continue


year = input()
year = list(year)
for (i, v) in enumerate(year):
	year[i] = int(v)
flag = True
while flag:
	year[3] += 1
	if year[3] == 10:
		year[3] = 0
		year[2] += 1
		if year[2] == 10:
			year[2] = 0
			year[1] += 1
			if year[1] == 10:
				year[1] = 0
				year[0] += 1
	lets_break = False
	for i in range(0, 4):
		for j in range(i + 1, 4):
			if year[i] == year[j]:
				lets_break = True
				break
		if lets_break:
			break
	if not lets_break:
		flag = False
		for (i, v) in enumerate(year):
			year[i] = str(v)
		print(''.join(year))


i = int(input()) + 1

def isgood(i):
	i = str(i)
	for j in i:
		if i.count(j) > 1:
			return False
	return True
while not isgood(i):
	i += 1
print(i)


a = input()
i = int(a) + 1
i = str(i)
while len(set(i)) != 4:
	i = int(i) + 1
	i = str(i)
print(i)


import sys

class Scanner:

	def __init__(self):
		self.current_tokens = []

	def remaining_tokens(self):
		return len(self.current_tokens)

	def nextline(self):
		assert self.remaining_tokens() == 0, 'Reading next line with remaining tokens'
		return input()

	def nexttokens(self):
		return self.nextline().split()

	def nexttoken(self):
		if len(self.current_tokens) == 0:
			self.current_tokens = self.nexttokens()
		assert self.remaining_tokens() > 0, 'Not enough tokens to parse.'
		return self.current_tokens.pop(0)

	def nextints(self, n=-1):
		if n == -1:
			return list(map(int, self.nexttokens()))
		else:
			return (self.nextint() for i in range(n))

	def nextint(self):
		return int(self.nexttoken())

def quit():
	sys.exit(0)
stdin = Scanner()
nextint = stdin.nextint
nextints = stdin.nextints
nextline = stdin.nextline
n = nextint()

def isdistinct(n):
	seen = []
	for i in str(n):
		if i in seen:
			return False
		seen.append(i)
	return True
while True:
	n += 1
	if isdistinct(n):
		print(n)
		quit()


year = int(input())
n = year

def check(m):
	digit = []
	while m > 0:
		digit.append(int(m) % 10)
		m = int(m) // 10
	flag = True
	for i in range(len(digit)):
		if flag:
			for j in range(len(digit)):
				if i != j and digit[i] == digit[j]:
					flag = False
					break
		else:
			break
	return flag
while True:
	n = n + 1
	if check(n):
		print(n)
		break


def compare(current):
	typed = []
	typed.append(int(current / 1000))
	typed.append(int(current / 100 % 10))
	typed.append(int(current / 10 % 10))
	typed.append(int(current % 10))
	y = 0
	for x in range(4):
		if typed[0] is typed[1] or typed[0] is typed[2] or typed[0] is typed[3]:
			y = y + 1
		if typed[1] is typed[0] or typed[1] is typed[3] or typed[1] is typed[2]:
			y = y + 1
		if typed[2] is typed[0] or typed[2] is typed[3] or typed[2] is typed[1]:
			y = y + 1
		if typed[3] is typed[0] or typed[3] is typed[1] or typed[3] is typed[2]:
			y = y + 1
	return y
current = int(input())
current += 1
while True:
	if compare(current) == False:
		print(current)
		break
	current += 1


a = input()
a = int(a)
temp = a + 1
while temp > a:
	temp1 = temp
	e = temp % 10
	temp = temp / 10
	temp = int(temp)
	f = temp % 10
	temp = temp / 10
	temp = int(temp)
	g = temp % 10
	temp = temp / 10
	temp = int(temp)
	h = temp % 10
	if e == f or f == g or g == h or (e == g) or (e == h) or (f == h):
		temp = temp1 + 1
	elif e != f and f != g and (g != h) and (e != g) and (e != h) and (f != h):
		print(temp1)


a = int(input())
d = []
for i in range(a + 1, 9100):
	d.clear()
	b = i
	c = i
	while b != 0:
		b = b % 10
		c = c // 10
		d.append(b)
		b = c
	if len(set(d)) == 4:
		print(i)
		break


n = int(input())
m = 0
while True:
	n = n + 1
	l = list(str(n))
	l = set(l)
	if len(l) == 4:
		print(n)
		break


y = int(input())
y += 1
distinct = False

def unique(y):
	result = True
	t = str(y)
	for i in t:
		if t.count(i) != 1:
			result = False
			return result
	return result
while True:
	if unique(y) == True:
		print(y)
		break
	else:
		y += 1


year = input('')
y = int(year)
i = 0
while True:
	i = i + 1
	ny = y + i
	a = str(ny)
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		print(a)
		break


m = int(input())
while 1:
	m = m + 1
	n = str(m)
	a = set([n[0], n[1], n[2], n[3]])
	if len(a) == 4:
		print(n)
		break


def aa(n):
	n = str(n)
	n = set(list(n))
	if len(n) == 4:
		return True
	else:
		return False
n = int(input())
k = 0
for i in range(n + 1, 9050):
	if aa(i):
		k = i
		break
print(k)


a = input()

def BeautifulYear(x):
	b = int(a) + 1
	while len(a) - len(set(str(b))) != 0:
		b += 1
	return b
print(BeautifulYear(a))


year = input()

def has_distinct_digits(year):
	for i in range(len(year)):
		for j in range(len(year)):
			if j > i and year[i] == year[j]:
				return False
	return True
next_year = str(int(year) + 1)
while not has_distinct_digits(next_year):
	next_year = str(int(next_year) + 1)
print(next_year)


num = int(input())
for i in range(num + 1, 10000):
	n = i
	list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
	count = 0
	a = n % 10
	if a in list:
		list.remove(a)
	n = n // 10
	b = n % 10
	if b in list:
		list.remove(b)
	else:
		count = count + 1
	if count == 0:
		n = n // 10
		c = n % 10
		if c in list:
			list.remove(c)
		else:
			count = count + 1
	if count == 0:
		n = n // 10
		d = n % 10
		if d in list:
			list.remove(d)
		else:
			count = count + 1
	if count == 0:
		print(i)
		break


current = int(input())
answer = False
while not answer:
	current += 1
	string = str(current)
	digits = []
	for digit in string:
		if digit in digits:
			break
		else:
			digits.append(digit)
			if len(digits) == 4:
				answer = True
print(current)


s = input()
s = str(int(s) + 1)
while s.count(s[0]) != 1 or s.count(s[1]) != 1 or s.count(s[2]) != 1 or (s.count(s[3]) != 1):
	s = str(int(s) + 1)
print(s)


n = input()
m = int(n) + 1
while len(''.join(list(set(str(m))))) < 4:
	m += 1
print(m)


y = int(input().strip())
y += 1
while True:
	if len(set(list(str(y)))) != len(list(str(y))):
		y += 1
	else:
		print(y)
		break


from sys import stdin, stdout
year = int(stdin.readline())
year += 1

def digit(num):
	l = []
	while num:
		l.append(num % 10)
		num = num // 10
	s = set(l)
	if len(s) == len(l):
		return True
	else:
		return False
while True:
	if digit(year):
		stdout.write(str(year) + '\n')
		break
	else:
		year += 1


num = int(input()) + 1
while len(set([int(x) for x in str(num)])) < 4:
	num += 1
print(num)


n = int(input())
cont = True
check = ''
while cont:
	n += 1
	for char in str(n):
		if char == str(n)[-1]:
			if char in check:
				cont = True
				break
			else:
				cont = False
				check += char
				continue
		elif char in check:
			cont = True
			break
		else:
			cont = True
			check += char
	check = ''
print(n)


y = int(input()) + 1
sy = set(str(y))
while len(sy) < 4:
	y += 1
	sy = set(str(y))
print(y)


n = int(input())
while True:
	n += 1
	if len(set(str(n))) == len(str(n)):
		print(n)
		quit()


a = input()
b = int(a)
ok = 1
while ok:
	b += 1
	c = str(b)
	flag = 1
	for i in range(len(c)):
		for j in range(i + 1, len(c)):
			if c[i] == c[j]:
				flag = 0
	ok = 1 - flag
print(b)


year = int(input())
a = 1
fake = year
while a > 0:
	fake += 1
	y = str(fake)
	if y[0] != y[1] and y[0] != y[2] and (y[0] != y[3]) and (y[1] != y[2]) and (y[1] != y[3]) and (y[2] != y[3]) and (fake > year):
		print(fake)
		a = 0


def pretty_year(y):
	numbs = set()
	for i in str(y):
		if i in numbs:
			return False
		numbs.add(i)
	return True
y = int(input()) + 1
while not pretty_year(y):
	y += 1
print(y)


def unique(N):
	N = str(N)
	for i in range(len(N)):
		for j in range(i + 1, len(N), 1):
			if N[i] == N[j]:
				return True
	return False
N = input()
N = int(N)
N = N + 1
while unique(N):
	N = int(N)
	N = N + 1
print(N)


y = int(input())
i = y
flag = 0
while 1:
	if len(set(str(i))) == 4:
		if i - y > 0:
			flag = 1
			ans = i
	if flag == 1:
		break
	i += 1
print(ans)


def check(s):
	diff = []
	for i in range(len(s)):
		if s[i] in diff:
			return False
		else:
			diff.append(s[i])
	return True
(year, key) = (int(input()), False)
while not key:
	year += 1
	key = check(str(year))
print(year)


a = int(input())
s = set()
for i in range(a + 1, 9999):
	s = set()
	p = str(i)
	for j in p:
		if j not in s:
			s.add(j)
	if len(s) == 4:
		print(i)
		break


y = int(input())
for i in range(y + 1, 10000):
	lis = []
	year = str(i)
	for j in range(4):
		lis.append(year[j])
	s = set(lis)
	if len(s) == 4:
		print(i)
		break


base_year = int(input())

def has_distinct_digits(year):
	digits = []
	for digit in year:
		if digit in digits:
			return False
		else:
			digits.append(digit)
	return True
year = base_year + 1
while not has_distinct_digits(str(year)):
	year += 1
print(year)


d = int(input())
xd = set()
while len(xd) != len(str(d)):
	d += 1
	for i in str(d):
		xd.add(i)
	if len(xd) == len(str(d)):
		print(d)
	else:
		xd = set()


n = int(input())
found = False
while not found:
	n += 1
	if str(n)[2] != str(n)[0] != str(n)[1] != str(n)[2] != str(n)[3] != str(n)[1] != str(n)[0] != str(n)[3]:
		found = True
print(n)


def is_good(n):
	s = set()
	st = str(n)
	for ch in st:
		s.add(ch)
	return len(s) == len(st)
year = int(input()) + 1
while not is_good(year):
	year += 1
print(year)


from sys import stdin
(lines, line_index) = (stdin.readlines(), -1)

def get_line():
	global lines, line_index
	line_index += 1
	return lines[line_index]

def main():
	n = int(get_line()) + 1
	while len(set(str(n))) < 4:
		n += 1
	print(n)
main()


def f(n):
	return len(set(list(str(n)))) == 4
n = int(input()) + 1
while not f(n):
	n += 1
print(n)


s = int(input())
n = str(s + 1)
while True:
	k = []
	for i in n:
		if i not in k:
			k.append(i)
	if len(n) == len(k):
		break
	else:
		n = str(int(n) + 1)
print(n)


year_number = int(input())
is_strictly_larger = False
while not is_strictly_larger:
	year_number += 1
	year_number_string = str(year_number)
	year_number_set = set(year_number_string)
	if len(year_number_string) == len(year_number_set):
		is_strictly_larger = True
print(year_number)


year = int(input()) + 1
distinct = False
while True:
	yearSet = set(str(year))
	yearList = list(str(year))
	if len(yearSet) == len(yearList):
		distinct = True
		break
	year += 1
print(year)


year = int(input())
flag = 0
while True:
	year = str(int(year) + 1)
	if len(set(year)) == 4:
		flag = 1
		break
if flag == 1:
	print(year)


a = ''

def c(a):
	n = 0
	for i in range(10):
		if n < a.count(str(i)):
			n = a.count(str(i))
	return n
y = int(input())
while y < 10000:
	y = y + 1
	if c(str(y)) == 1:
		print(y)
		break


i = input()
si = 0
while int(i) != si:
	i = int(i) + 1
	i = str(i)
	ii = list(i)
	if ii[1] != ii[0] and ii[2] != ii[0] and (ii[3] != ii[0]) and (ii[1] != ii[2]) and (ii[1] != ii[3]) and (ii[2] != ii[3]):
		si = int(i)
print(i)


a = int(input())
if a == 1987:
	print(2013)
else:
	val = 2013
	for i in range(1, 8001):
		val = a + i
		x = set(list(str(val)))
		if len(x) == 4:
			break
	print(val)


n = int(input()) + 1
l = list(map(int, str(n)))
s = set(l)
while len(l) != len(s):
	n += 1
	l = list(map(int, str(n)))
	s = set(l)
print(n)


n = int(input())
flag = 0
while flag == 0:
	n += 1
	lst = list(str(n))
	lst.sort()
	if lst[0] != lst[1] and lst[1] != lst[2] and (lst[3] != lst[2]):
		flag = 1
print(n)


inputNumber_ = input()
inputNumber = int(inputNumber_)

def isRepeated(inNumber):
	for index in range(len(inNumber)):
		tempNo = inNumber[:index] + inNumber[index + 1:]
		if inNumber[index] in tempNo:
			return 1
	return 0
x = 1
while x == 1:
	inputNumber += 1
	x = isRepeated(str(inputNumber))
print(inputNumber)


def distinct(num):
	for i in num:
		if num.count(i) > 1:
			return False
	return True
n = int(input())
while True:
	if distinct(str(n + 1)):
		print(n + 1)
		break
	else:
		n = n + 1


def year(x):
	b = str(x)
	b = len(set(b))
	return b
a = 1 + int(input())
while year(a) != 4:
	a += 1
print(a)


year = int(input()) + 1
while True:
	y = list(str(year))
	s = set(y)
	if len(s) == len(y):
		break
	year += 1
print(year)


def checker(n):
	l = list(str(n))
	if len(set(l)) == len(l):
		return True
	return False
n = int(input())
n += 1
while True:
	if checker(n):
		print(n)
		break
	n += 1


import collections as c

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	while True:
		N += 1
		if len(set(list(str(N)))) == len(str(N)):
			return N
ans = solve()
print(ans)


input_str = input()
input_int = int(input_str)
input_int += 1
while 1:
	if len(list(str(input_int))) == len(set(str(input_int))):
		result = input_int
		break
	else:
		input_int += 1
print(result)


def hasDistinctDigits(n):
	x = str(n)
	return list(sorted(set(x))) == list(sorted(x))
n = int(input())
n += 1
while hasDistinctDigits(n) == False:
	n += 1
print(n)


def unique(n):
	n = str(n)
	qwe = []
	for i in n:
		qwe.append(i)
	for i in qwe:
		count = 0
		for j in qwe:
			if j == i:
				count += 1
		if count > 1:
			return False
	return True
n = int(input())
n += 1
while not unique(n):
	n += 1
print(n)


p = int(input())
m = 1
l = p + 1
while m != 0:
	l1 = l % 10
	l2 = l // 10 % 10
	l3 = l // 100 % 10
	l4 = l // 1000 % 10
	if l1 == l2 or l1 == l3 or l1 == l4 or (l2 == l3) or (l2 == l4) or (l3 == l4):
		l = l + 1
	else:
		m = 0
print(l)


n = list(input())
ori = n
while len(set(n)) != len(n) or n == ori:
	n = list(str(int(''.join(n)) + 1))
print(''.join(n))


init_year = int(input())
i = init_year + 1
while True:
	str_i = str(i)
	digits_i = list(str_i)
	digits_i.sort()
	u_digits_i = list(set(str_i))
	u_digits_i.sort()
	if digits_i == u_digits_i:
		print(i)
		break
	i += 1


year_str = input()
temp = 0
while True:
	test = False
	year_int = int(year_str) + 1
	year_str = str(year_int)
	for i in range(0, 4):
		for j in range(0, 4):
			if i == j:
				continue
			if year_str[i] == year_str[j]:
				test = True
	if test == False:
		break
print(year_int)


s = int(input())
j = []
if 8977 <= s <= 9000:
	print(9012)
	quit()
for e in range(1000, 9000):
	e = str(e)
	if e[0] != e[1] and e[0] != e[2] and (e[0] != e[3]) and (e[1] != e[2]) and (e[1] != e[3]) and (e[2] != e[3]):
		j.append(int(e))
if s not in j:
	j.append(s)
j.sort()
i = j.index(s)
print(j[i + 1])


n = eval(input())
while n <= 9000 and n >= 1000:
	i = n + 1
	while i <= 9012:
		s = str(i)
		n = len(set(s))
		if n == 4:
			print(s)
			break
		else:
			i = i + 1
	break


yr = input()
n = int(yr)
n += 1
yr = str(n)
flag = 0
while flag == 0:
	count = 0
	for i in range(4):
		for j in range(i + 1, 4):
			if yr[i] != yr[j]:
				count += 1
		if count == 6:
			flag = 1
			print(yr)
			break
	n = int(yr)
	n += 1
	yr = str(n)


import os
import sys
t = 0
s = input()
l = len(s)
c = int(s)
c = c + 1
s = str(c)
for k in range(1, 10000):
	for i in range(0, l - 1):
		for j in range(i + 1, l):
			t = 0
			if s[i] == s[j]:
				t = 5
				break
		if t == 5:
			break
	if t != 5:
		print(s)
		break
	else:
		p = int(s)
		p = p + 1
		s = str(p)


s = input()

def year(s):
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		return s
	else:
		return year(str(int(s) + 1))
print(year(str(int(s) + 1)))


a = int(input())
b = 0
c = 0
d = 0
e = 0
x = 0
while True:
	a = a + 1
	b = a // 1000
	c = a // 100 % 10
	d = a // 10 % 10
	e = a % 10
	if b != c and b != d and (b != e) and (c != d) and (c != e) and (d != e):
		break
print(a)


n = int(input())
a = 0
while a != len(str(n)):
	a = 0
	n += 1
	l = list(str(n))
	for j in l:
		s = 0
		for k in l:
			if j == k:
				s += 1
			else:
				continue
		if s > 1:
			break
		else:
			a += 1
			continue
print(str(n))


y = input()
L = list(set(y))
r = True
while len(y) == len(L):
	y = str(int(y) + 1)
	L = list(set(y))
	if len(L) == 4:
		print(y)
		r = False
		break
if r is True:
	while len(y) > len(L):
		y = str(int(y) + 1)
		L = list(set(y))
	print(y)


def isDistinct(year):
	digList = list()
	year = str(year)
	for dig in year:
		if dig not in digList:
			digList.append(dig)
	if len(digList) < 4:
		return False
	else:
		return True
year = int(input())
distinctYears = list()
for i in range(1000, 9000):
	if isDistinct(i):
		distinctYears.append(i)
if isDistinct(year):
	for i in range(len(distinctYears)):
		if distinctYears[i] == year:
			print(distinctYears[i + 1])
else:
	while not isDistinct(year):
		year += 1
	print(year)


year = int(input())
while True:
	year += 1
	a = 0
	for i in str(year):
		if str(year).count(i) != 1:
			a += 1
	if a == 0:
		print(year)
		break


year = int(input())

def check(a, b, c, d):
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		return False
	else:
		return True
while True:
	year += 1
	yearstr = str(year)
	if check(yearstr[0], yearstr[1], yearstr[2], yearstr[3]):
		print(year)
		break


s = input()
a = 1
while a:
	n = int(s)
	n += 1
	s = str(n)
	count1 = 0
	for i in s:
		if s.count(i) == 1:
			count1 += 1
	if count1 == 4:
		print(s)
		break


def differ_digit(a_year):
	a_year = str(a_year)
	for i in range(len(a_year)):
		for j in range(i + 1, len(a_year)):
			if a_year[i] == a_year[j]:
				return False
	return True

def beautifulYear(a_year):
	a_year = int(a_year)
	result_year = a_year + 1
	while not differ_digit(result_year):
		result_year += 1
	print(result_year)
a_year = input()
beautifulYear(a_year)


n = int(input())
p = 0
while p != 1:
	n = n + 1
	no = str(n)
	for i in range(3):
		for j in range(i + 1, 4):
			if no[i] == no[j]:
				p = 0
				break
			else:
				p = 1
		if p == 0:
			break
print(n)


def distinct(y):
	z = str(y)
	s = sorted(z)
	return s[0] != s[1] and s[1] != s[2] and (s[2] != s[3])
y = int(input()) + 1
while not distinct(y):
	y += 1
print(y)


def beauty(n):
	l = []
	while n > 0:
		if not n % 10 in l:
			l.append(n % 10)
		else:
			return False
		n = int(n / 10)
	return True
year = input()
year = int(year)
newyear = year + 1
while not beauty(newyear):
	newyear += 1
print(newyear)


s = int(input())
while True:
	s += 1
	t = s // 1000
	h = s % 1000 // 100
	d = s % 100 // 10
	e = s % 10
	if t != h and t != d and (t != e) and (h != d) and (h != e) and (d != e):
		break
print(s)


n = input()
t = int(n)
t = t + 1
n = str(t)
while True:
	if n[0] != n[1] and n[2] != n[3] and (n[1] != n[3]) and (n[2] != n[0]) and (n[0] != n[3]) and (n[1] != n[2]):
		print(n)
		exit()
	else:
		t = int(n)
		t = t + 1
		n = str(t)


def dif(n):
	lista = []
	n = str(n)
	for i in n:
		n = int(n)
		i = int(i)
		lista.append(i)
	if lista[1] == lista[0]:
		n += 100
		n -= lista[2] * 10 + lista[3]
		dif(n)
	elif lista[2] == lista[0]:
		n += 10
		n -= lista[3]
		dif(n)
	elif lista[2] == lista[1]:
		n += 10
		n -= lista[3]
		dif(n)
	elif lista[3] == lista[0]:
		n += 1
		dif(n)
	elif lista[3] == lista[1]:
		n += 1
		dif(n)
	elif lista[3] == lista[2]:
		n += 1
		dif(n)
	else:
		print(n)
n = int(input()) + 1
dif(n)


i = int(input())
i = i + 1
while i > 0:
	n = str(i)
	x = list(n)
	y = list(set(n))
	if sorted(x) == sorted(y):
		print(i)
		break
	i += 1


n = int(input())
while 1:
	n += 1
	m = str(n)
	a = m.count('0')
	b = m.count('1')
	c = m.count('2')
	d = m.count('3')
	e = m.count('4')
	f = m.count('5')
	g = m.count('6')
	h = m.count('7')
	i = m.count('8')
	j = m.count('9')
	if max(a, b, c, d, e, f, g, h, i, j) < 2:
		print(n)
		break


n = int(input())
n += 1
f = n
a = n % 10
n = n // 10
b = n % 10
n = n // 10
c = n % 10
n = n // 10
d = n
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	n = f + 1
	a = n % 10
	n = n // 10
	b = n % 10
	n = n // 10
	c = n % 10
	n = n // 10
	d = n
	f += 1
print(d, end='')
print(c, end='')
print(b, end='')
print(a, end='')


def distinct(y):
	k = str(y)
	for i in range(3):
		if k[i] in k[i + 1:]:
			return False
	else:
		return True
n = int(input())
while n <= 10000000:
	n += 1
	c = distinct(n)
	if c:
		print(n)
		break


year = int(input(''))
count = 0

def isUniqueChars(st):
	char_set = [False] * 128
	for i in range(0, len(st)):
		val = ord(st[i])
		if char_set[val]:
			return False
		char_set[val] = True
	return True
x = True
year += 1
while x == True:
	word = str(year)
	if isUniqueChars(word) == True:
		x = False
	else:
		year = int(word)
		year += 1
		continue
print(word)


a = int(input()) + 1

def ch(a):
	b = 0
	c = 0
	while b < len(a):
		if a.count(a[b]) > 1:
			c = 1
		b += 1
	if c == 1:
		return 0
	elif c == 0:
		return 1
while ch(str(a)) == 0:
	a += 1
print(a)


y = int(input())
for i in range(y + 1, 9013):
	a = len(list(str(i)))
	b = len(set(list(str(i))))
	if a == b:
		print(i)
		break
	else:
		continue


year = int(input())
year += 1
while True:
	d = {}
	for letter in str(year):
		d[letter] = d.get(letter, 0) + 1
	if max(d.values()) > 1:
		year += 1
	else:
		break
print(year)


from sys import stdin
input = stdin.readline
a = input()
for i in range(int(a) + 1, 9999):
	if len(set(list(str(i)))) != 4:
		continue
	print(i)
	break


god = int(input()) + 1
while len(set(str(god))) <= 3:
	god += 1
print(god)


p = int(input())
p += 1
u = str(p)
a = int(u[0])
b = int(u[1])
c = int(u[2])
d = int(u[3])
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	p += 1
	u = str(p)
	a = int(u[0])
	b = int(u[1])
	c = int(u[2])
	d = int(u[3])
print(p)


a = input()
l = 0
while l < len(str(a)):
	a = int(a) + 1
	s = set(str(a))
	l = len(s)
print(a)


y = int(input())
while True:
	y += 1
	x = str(y)
	if x.count('1') <= 1 and x.count('2') <= 1 and (x.count('3') <= 1) and (x.count('4') <= 1) and (x.count('5') <= 1) and (x.count('6') <= 1) and (x.count('7') <= 1) and (x.count('8') <= 1) and (x.count('9') <= 1) and (x.count('0') <= 1):
		print(x)
		break


s = input()
n = int(s)
m = 0
if n >= 1987 and n < 2013:
	print(2013)
else:
	while m != 1:
		n = n + 1
		s = '' + str(n)
		x = list(s)
		for i in range(0, len(x)):
			m = x.count(x[i])
			if m != 1:
				break
	print(n)


for _ in range(int(input()) + 1, 90000000):
	if set(str(_)).__len__() == 4:
		print(_)
		break


a = int(input())
while 1:
	b = []
	for i in range(0, 10):
		b.append(0)
	a += 1
	temp = a
	while temp > 0:
		r = temp % 10
		b[r] += 1
		temp = temp // 10
	f = 1
	for i in range(0, 10):
		if b[i] > 1:
			f = 0
	if f == 1:
		break
print(a)


s = int(input())
j = 1
i = 1
while j == 1:
	n = str(s + i)
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		print(n)
		break
	i = i + 1


y = int(input())
by = str(y + 1)
while len(set(by)) != 4:
	y += 1
	by = str(y + 1)
print(y + 1)


n = int(input()) + 1
while len([str(n).count(i) for i in '1234567890' if str(n).count(i) == 1]) != 4:
	n += 1
print(n)


n = int(input())
s = False
while s == False:
	n += 1
	if len(set(str(n))) == 4:
		s = True
print(n)


n = int(input())
n += 1
n = str(n)
while not (n[0] != n[1] and n[2] != n[3] and (n[0] != n[2]) and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3])):
	n = str(int(n) + 1)
print(n)


s = input()
n = int(s)
s = str(n + 1)
c = 0
while len(set(s)) != 4:
	n += 1
	c = 1
	s = str(n)
else:
	print(s)


n = int(input())

def distinctDig(x):
	s = str(x)
	set = {' '}
	for i in range(0, len(s)):
		if s[i] in set:
			return False
		else:
			set.add(s[i])
	return True
while distinctDig(n + 1) == False:
	n = n + 1
print(n + 1)


y = input()
for i in range(int(y) + 1, 9013):
	dict = {}
	for c in str(i):
		dict[c] = 1
	if len(dict) == 4:
		print(i)
		exit()


n = int(input())
test = 1
while test:
	test = 0
	n += 1
	n1 = n
	arr = []
	while n1:
		arr.append(n1 % 10)
		n1 //= 10
	i = 0
	while i < 3:
		j = i + 1
		while j <= 3:
			if arr[i] == arr[j]:
				test = 1
				break
			j += 1
		if test == 1:
			break
		i += 1
print(n)


year = int(input())
while True:
	year += 1
	l = []
	count = 0
	for i in str(year):
		if i not in l:
			l.append(i)
			count += 1
	if count == 4:
		print(year)
		break


def check(y):
	y = list(str(y))
	for i in range(0, len(y)):
		y[i] = int(y[i])
	c = 0
	mem = []
	for i in y:
		if i in mem:
			c += 1
			break
		mem.append(i)
	if c == 0:
		mem.clear()
		return True
	else:
		mem.clear()
		return False
year = int(input())
year = year + 1
while not check(year):
	year += 1
print(year)


n = int(input())
x = 0
while x != 6:
	x = 0
	n += 1
	s = str(n)
	for i in range(3):
		for j in range(i + 1, 4):
			if s[i] != s[j]:
				x += 1
print(n)


def distinct(x):
	line = list(str(x))
	for i in line:
		if line.count(i) > 1:
			return False
	return True
yy = int(input())
yy += 1
while not distinct(yy):
	yy += 1
print(yy)


n = int(input())
while n < 1000 or n > 9000:
	print('Numbers should be 4 digits  between 1000 and 9000')
	n = int(input())
n += 1
while len(set(str(n))) != 4:
	n += 1
print(n)


def seperateints(x):
	k = ''
	l = []
	for i in x:
		if i == ' ':
			l.append(int(k))
			k = ''
			continue
		k = k + i
	l.append(int(k))
	return l

def luckynum(x):
	for i in x:
		if i != '4' and i != '7':
			return False
	return True
x = int(input()) + 1
s = str(x)
while True:
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		break
	x += 1
	s = str(x)


year = int(input())
unique = year + 1
while True:
	flag = 0
	s = str(unique)
	check = []
	for i in s:
		if i in check:
			flag = 1
			break
		else:
			check.append(i)
	if flag == 0:
		print(unique)
		break
	unique += 1


a = int(input())
a += 1
while True:
	j = []
	b = str(a)
	for k in range(len(b)):
		j.append(b[k])
	if len(set(j)) == len(b):
		break
	a += 1
print(a)


def years(n):
	b = 1
	while b < 4:
		n = n + 1
		b = len(set(str(n)))
	print(n)
years(int(input()))


import sys
import math
y = int(sys.stdin.readline())
k = y
while 1:
	k += 1
	vstr = str(k)
	if vstr[0] != vstr[1] and vstr[0] != vstr[2] and (vstr[0] != vstr[3]) and (vstr[1] != vstr[2]) and (vstr[2] != vstr[3]) and (vstr[1] != vstr[3]):
		print(vstr)
		exit()


s = int(input())
flag = 0

def test(s, i=0, summ=0):
	s = str(s)
	for i in range(0, 3):
		for j in range(i + 1, 4):
			if s[i] != s[j]:
				summ += 1
	if summ == 6:
		return 1
	else:
		return 0
if test(s) == 1:
	s = s + 1
while flag == 0:
	if test(s) == 1:
		flag = 1
		print(s)
		break
	else:
		s += 1


num = int(input())
for i in range(num + 1, 10000):
	leng = len(str(num))
	myset = set(str(i))
	if len(myset) == leng:
		print(i)
		break


n = input()
year = int(n)
year += 1
yearstr = str(year)
while True:
	yearstr = str(year)
	l = list(yearstr)
	s = set(l)
	ll = len(l)
	ls = len(s)
	if ll == ls:
		print(year)
		break
	year += 1


t = int(input())
t += 1
while True:
	y = []
	n = t
	while n != 0:
		if n % 10 not in y:
			y.append(n % 10)
		else:
			break
		n //= 10
	t1 = str(t)
	if len(y) == len(t1):
		print(t)
		break
	t += 1


a = int(input())
for i in range(a + 1, 9013):
	b = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	k = i
	while k > 0:
		b[int(k % 10)] += 1
		k = k // 10
	for j in range(10):
		if b[j] >= 2:
			break
	if b[9] >= 2 or j < 9:
		continue
	else:
		print(i)
		break


year = int(input())
a = ''
for i in range(year + 1, 9013):
	i = list(str(i))
	if i[0] == i[1] or i[0] == i[2] or i[0] == i[3] or (i[1] == i[2]) or (i[1] == i[3]) or (i[2] == i[3]):
		continue
	else:
		for j in i:
			a = a + j
		print(a)
		break


def func(n):
	while True:
		n += 1
		if str(n)[0] != str(n)[1] and str(n)[0] != str(n)[2] and (str(n)[0] != str(n)[3]):
			if str(n)[1] != str(n)[2] and str(n)[1] != str(n)[3]:
				if str(n)[2] != str(n)[3]:
					print(n)
					return
n = int(input())
func(n)


def isdistinct(n):
	l = []
	while n > 0:
		digit = n % 10
		if digit not in l:
			l.append(digit)
		n = n // 10
	return len(l) == 4
t = int(input())
if t > 1987 and t < 2013:
	print(2013)
else:
	for j in range(1, 9000):
		if isdistinct(t + j):
			print(t + j)
			exit()


year = input()

def is_distinct(year):
	distinct = dict()
	for digit in year:
		distinct[digit] = 0
	if len(distinct) == len(year):
		return True
	return False
i = int(year) + 1
while True:
	if is_distinct(str(i)):
		print(i)
		break
	i += 1


def shred(num):
	double = []
	while num > 0:
		rem = num % 10
		double.append(rem)
		num //= 10
	return double

def check_list(double):
	for i in range(len(double)):
		for j in range(len(double)):
			if i != j:
				if double[i] == double[j]:
					return True
	return False
y = int(input())
n = y
double = []
double = shred(y)
out = check_list(double)
if out == False:
	one_more_time = True
else:
	one_more_time = False
while check_list(double) or one_more_time:
	y += 1
	double = shred(y)
	one_more_time = False
print(y)


def isDistinct(year):
	year = str(year)
	count = 0
	a = [0] * 10
	for i in range(len(year)):
		a[int(year[i]) - 1] += 1
	for j in range(10):
		if a[j] == 1:
			count += 1
	if count == len(year):
		return True
	else:
		return False
num = int(input())
i = 0
num = num + 1
while not isDistinct(num):
	num += 1
print(num)


year = int(input())
year = year + 1
n = year
while n != 0:
	first_number = n % 10
	n = int(n / 10)
	second_number = n % 10
	n = int(n / 10)
	third_number = n % 10
	n = int(n / 10)
	forth_number = n % 10
	n = int(n / 10)
	n = year
	if first_number != second_number and first_number != third_number and (first_number != forth_number) and (second_number != third_number) and (second_number != forth_number) and (third_number != forth_number):
		print(n)
		break
	else:
		year = year + 1
		n = year


def main():
	val = int(input()) + 1
	while len(set(str(val))) != 4:
		val += 1
	print(val)
main()


n = int(input()) + 1
l = [str(x) for x in str(n)]
a = int(''.join(l))
while len(set(l)) != 4:
	a += 1
	l = [int(x) for x in str(a)]
print(''.join([str(x) for x in l]))


year = int(input())
distinct = 'no'
while distinct != 'yes':
	year += 1
	a = []
	for i in str(year):
		if i not in a:
			a.append(i)
			distinct = 'yes'
		else:
			distinct = 'no'
			break
print(year)


n = int(input())
n = n + 1
n = str(n)
x = set(n)
while len(x) != len(n):
	n = int(n)
	n = n + 1
	n = str(n)
	x = set(n)
print(n)


y = int(input())
m = y + 1
while m > y:
	str1 = str(m)
	if len(set(str1)) == 4:
		print(m)
		break
	else:
		m = m + 1


n = int(input())
n += 1
chk = True
while chk:
	n = list(str(n))
	for i in range(4):
		if n.count(n[i]) > 1:
			break
		elif i == 3:
			chk = False
	if chk:
		n = int(''.join(n))
		n += 1
print(int(''.join(n)))


year = int(input())
temp_list = []
while 1:
	temp_list = []
	year += 1
	for i in str(year):
		if not i in temp_list:
			temp_list.append(i)
		else:
			break
	if len(temp_list) == 4:
		print(year)
		break


number = int(input())
arr = []
finish = 10000
number = number + 1
for i in range(number, finish):
	arr = list(map(int, str(i)))
	if arr[0] != arr[1] and arr[0] != arr[2] and (arr[0] != arr[3]) and (arr[1] != arr[2]) and (arr[1] != arr[3]) and (arr[2] != arr[3]):
		print(i)
		break


def nextYear(n):
	(a, b) = ([], [])
	n = str(n)
	for i in n:
		a.append(i)
	for k in a:
		if k not in b:
			b.append(k)
	if b == a:
		return True
	else:
		return False
n = int(input())
if nextYear(n) == False:
	while nextYear(n) == False:
		n += 1
	print(n)
else:
	while True:
		if nextYear(n + 1) == True:
			print(n + 1)
			break
		n += 1


def main():
	year = int(input())
	while True:
		year += 1
		year_list = list(str(year))
		check1 = len(year_list)
		year_set = set(year_list)
		check2 = len(year_set)
		if check1 == check2:
			print(year)
			break
		else:
			pass
main()


def main():
	current_year = int(input())
	new_year = current_year + 1
	while True:
		input_list = str(new_year)
		if int(input_list[0]) == int(input_list[1]) or int(input_list[0]) == int(input_list[2]) or int(input_list[0]) == int(input_list[3]) or (int(input_list[1]) == int(input_list[2])) or (int(input_list[1]) == int(input_list[3])) or (int(input_list[2]) == int(input_list[3])):
			dist = False
		else:
			dist = True
		if dist is True:
			print(input_list)
			break
		new_year = new_year + 1
main()


import functools
import logging
import os
import sys
import time
from typing import List
logger = logging.getLogger()
reader = sys.stdin
is_judge = os.getenv('DEBUGGING') is None

def timeit(func):

	@functools.wraps(func)
	def timed(*args, **kwargs):
		if is_judge:
			rv = func(*args, **kwargs)
		else:
			ts = time.time()
			rv = func(*args, **kwargs)
			te = time.time()
			logger.debug('performance %r %2.2fms', func.__name__, (te - ts) * 1000)
		return rv
	return timed

def is_distinct_int(n: int):
	digits = set()
	while n > 0:
		d = n % 10
		if d in digits:
			return False
		else:
			digits.add(d)
		n //= 10
	return True

def next_distinct(num: List[int]):
	if len(num) > 10:
		return None
	n = int(''.join([str(d) for d in num]))
	n += 1
	while n <= 9876543210:
		if is_distinct_int(n):
			return n
		else:
			n += 1

@timeit
def main():
	year = [int(d) for d in reader.readline().strip()]
	logger.debug(year)
	print(next_distinct(year))

def setup():
	global logger, reader
	if is_judge:
		logger.setLevel(logging.WARNING)
	else:
		handler = logging.StreamHandler(sys.stdout)
		handler.setLevel(logging.DEBUG)
		formatter = logging.Formatter('{asctime}s - {message}', style='{')
		handler.setFormatter(formatter)
		logger.addHandler(handler)
		logger.setLevel(logging.DEBUG)
		reader = open('input.txt')
setup()
try:
	main()
except KeyboardInterrupt:
	logger.debug('KeyboardInterrupt')
except IOError as e:
	logger.error(f'I/O error({e.errno}): {e.strerror}')


n = input()
num = int(n) + 1
while num <= 10000:
	var = str(num)
	c1 = var.count(var[0])
	c2 = var.count(var[1])
	c3 = var.count(var[2])
	c4 = var.count(var[3])
	if c1 == 1 and c2 == 1 and (c3 == 1) and (c4 == 1):
		print(var)
		break
	num += 1


def check(k):
	l = []
	while k > 0:
		m = k % 10
		l.append(m)
		k = k // 10
	for i in range(len(l)):
		for j in range(i + 1, len(l)):
			if l[i] == l[j]:
				return False
	return True
n = int(input())
i = n + 1
while i:
	if check(i):
		print(i)
		break
	i += 1


def isDistinct(year):
	digits = set([letter for letter in year])
	if len(digits) != 4:
		return False
	return True

def main():
	y = int(input())
	y += 1
	while not isDistinct(str(y)):
		y += 1
	print(y)
	return
main()


def hasDiffDigits(year):
	digits = set()
	for digit in str(year):
		if digit in digits:
			return False
		digits.add(digit)
	return True
year = int(input())
year += 1
while not hasDiffDigits(year):
	year += 1
print(year)


y = int(input())
y = y + 1
s1 = str(y)
a = s1.count(s1[0])
b = s1.count(s1[1])
c = s1.count(s1[2])
d = s1.count(s1[3])
while not a == b == c == d == 1:
	y = y + 1
	s1 = str(y)
	a = s1.count(s1[0])
	b = s1.count(s1[1])
	c = s1.count(s1[2])
	d = s1.count(s1[3])
print(y)


def checkIfDis(x):
	for i in x:
		if i != x[1] and i != x[2] and (i != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
			return True
		else:
			return False
yearI = int(input())
i = yearI + 1
ch = True
while ch is True:
	if checkIfDis(str(i)) == True:
		ch = False
		break
	i += 1
print(i)


from sys import stdin, stdout
inp = stdin.readline
out = stdout.write
n = int(inp().strip())
for i in range(n + 1, 9001):
	x = len(set(str(i)))
	if x == len(str(i)):
		out(str(i))
		break
else:
	out('9012')


y = int(input())
m = str(y + 1)
setA = set(m)
while len(setA) != 4:
	y += 1
	m = str(y + 1)
	setA = set(m)
print(m)


def is_happy(year):
	s = str(year)
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] == s[j]:
				return False
	return True
y = int(input()) + 1
while not is_happy(y):
	y += 1
print(y)


year_min = int(input())
while True:
	year_min += 1
	if len(set(str(year_min))) == len(str(year_min)):
		print(year_min)
		break


def dist(n):
	lis = []
	while n:
		if n % 10 not in lis:
			lis.append(n % 10)
		n = n // 10
	if len(lis) == 4:
		return 1
	else:
		return 0
n = int(input())
n += 1
while dist(n) == 0:
	n += 1
print(n)


year = int(input()) + 1
distinct = False
while not distinct:
	if len(set(list(str(year)))) == 4:
		print(year)
		distinct = True
	year += 1


n = int(input())
i = 0
n += 1
while True:
	string = str(n)
	l = len(string)
	s = set(string)
	l1 = len(s)
	if l1 == l:
		print(int(n))
		break
	else:
		n = n + 1


n = int(input())
k = n
while True:
	k = k + 1
	a = list([])
	t = k
	for i in range(4):
		if t > 0:
			a.append(t % 10)
			t = t // 10
	if a.count(a[0]) == 1 and a.count(a[1]) == 1 and (a.count(a[2]) == 1) and (a.count(a[3]) == 1):
		print(k)
		break


a = input()
b = int(a)
b = b + 1
while True:
	w = b / 1000
	w = int(w)
	x = b / 100 % 10
	x = int(x)
	y = b / 10 % 10
	y = int(y)
	z = b % 10
	z = int(z)
	if w != x and w != y and (w != z) and (x != y) and (x != z) and (y != z):
		print(b)
		break
	else:
		b = b + 1


year = str(input())
beauty = int(year)
while True:
	beauty += 1
	count = 0
	for i in str(beauty):
		if len(str(beauty).replace(i, '')) == 3:
			count += 1
		else:
			break
	if count == 4:
		break
print(beauty)


def isDistinct(yr):
	k = {}
	for i in [int(x) for x in str(yr)]:
		if i in k:
			return False
		else:
			k[i] = True

def Beautiful(year):
	while True:
		year += 1
		if isDistinct(year) != False:
			return year
usr = int(input())
print(Beautiful(usr))


a = int(input())
while True:
	rs = set()
	a += 1
	a = str(a)
	for i in a:
		rs.add(i)
	if len(rs) == len(a):
		print(a)
		break
	else:
		a = int(a)


y = int(input())
i = y + 1
while i < 10000:
	count = [0] * 10
	distincts = 0
	newY = i
	while newY:
		count[newY % 10] += 1
		newY = newY // 10
	for j in count:
		if j == 1:
			distincts += 1
	if distincts == 4:
		newY = i
		print(newY)
		break
	i += 1


x = int(input())

def year(x):
	x = x + 1
	while x != 0:
		if len(str(x)) == len(list(set(str(x)))):
			return x
		x += 1
print(year(x))


y = str(input())
a = set(y)
l2 = 0
itog = int(y)
while 4 != l2:
	itog += 1
	b = set(str(itog))
	l2 = len(b)
print(itog)


num = int(input()) + 1
while 1:
	if len(set(str(num))) == len(str(num)):
		print(num)
		break
	else:
		num += 1


y = int(input())
sgn = 1
for i in range(y + 1, 10000):
	if sgn == 0:
		break
	v = str(i)
	if v[0] != v[1] and v[0] != v[2] and (v[0] != v[3]) and (v[1] != v[2]) and (v[1] != v[3]) and (v[2] != v[3]):
		print(i)
		sgn = 0


def rep_digits(year):
	year = str(year)
	s = set()
	for i in year:
		s.add(i)
	if len(s) == 4:
		return False
	return True
year = int(input()) + 1
while rep_digits(year):
	year += 1
print(year)


def deci(b):
	while True:
		b = str(int(b) + 1)
		if len(set(b)) == 4:
			return b
b = int(input())
x = deci(b)
print(x)


a = int(input())

def nar(x, y):
	while True:
		if len(set(str(x))) == len(str(y)):
			return x
		else:
			x = x + 1
print(nar(a + 1, a))


n = int(input())
i = 0
n += 1
while i == 0:
	s = str(n)
	d = set(s)
	nd = len(d)
	if nd == len(s):
		i += 1
		print(n)
	n += 1


s = input()

def shubh(s):
	while True:
		s = str(int(s) + 1)
		if len(set(s)) == 4:
			return s
print(shubh(s))


input_year = int(input())
test_year = input_year

def distinct_digits_check(n):
	n_str = str(n)
	digit_dict = {}
	for s in n_str:
		digit_dict[s] = 0
	return len(digit_dict)
year_digits = 0
while year_digits != 4:
	test_year += 1
	year_digits = distinct_digits_check(test_year)
print(test_year)


n = int(input())
n += 1

def is_differ(n):
	if len(set(str(n))) == len(str(n)):
		return True
	else:
		return False
while not is_differ(n):
	n += 1
print(n)


n = int(input().strip()) + 1
while len(set(str(n))) != 4:
	n += 1
print(n)


def pretty(n):
	return len(set(str(n))) == 4
n = int(input())
for i in range(n + 1, 9013):
	if pretty(i):
		print(i)
		break


n = int(input())
for i in range(n + 1, 100000):
	a = list(str(i))
	b = list(set(a))
	if len(a) == len(b):
		print(i)
		break


s = int(input())
t = []
while True:
	s += 1
	t.clear()
	for x in str(s):
		if x not in t:
			t.append(x)
	if len(t) is len(str(s)):
		print(s)
		break


y = int(input())
n = 10000
for i in range(y, n):
	if i > y and len(set(str(i))) == 4:
		print(i)
		break


n = int(input())
a = 0
b = 0
c = 0
d = 0
while a == d or a == c or a == b or (b == d) or (b == c) or (c == d):
	n = n + 1
	d = n % 10
	c = n // 10 % 10
	b = n // 100 % 10
	a = n // 1000 % 10
d = str(d)
c = str(c)
b = str(b)
a = str(a)
g = a + b + c + d
print(int(g))


inp = int(input()) + 1
check = 0
while check != 3:
	for i in str(inp):
		if str(inp).count(i) != 1:
			inp += 1
			check = 0
			break
		elif check == 3:
			break
		else:
			check += 1
print(inp)


n = str(int(input()) + 1)
flag = True
while flag:
	flag = False
	for i in n:
		if n.count(i) >= 2:
			n = str(int(n) + 1)
			flag = True
print(n)


s = input()
a = 0
for i in range(1, 1000):
	if len(set(list(str(eval(s) + i)))) == 4:
		a = eval(s) + i
		break
print(a)


a = int(input())
while a < 9999:
	a += 1
	if len(set(str(a))) == 4:
		break
print(a)


s = input()

def unique_values(g):
	s = set()
	for x in g:
		if x in s:
			return False
		s.add(x)
	return True
while True:
	if unique_values(str(int(s) + 1)):
		break
	else:
		s = str(int(s) + 1)
		continue
print(int(s) + 1)


inttahun = int(input()) + 1
strtahun = str(inttahun)
jadi = False
while jadi != True:
	if strtahun[-1] in strtahun[:-1]:
		inttahun += 1
		strtahun = str(inttahun)
	elif strtahun[-2] in strtahun[:-2]:
		inttahun = (inttahun // 10 + 1) * 10
		strtahun = str(inttahun)
	elif strtahun[-3] in strtahun[:-3]:
		inttahun = (inttahun // 100 + 1) * 100
		strtahun = str(inttahun)
	elif strtahun[-4] in strtahun[:-4]:
		inttahun = (inttahun // 1000 + 1) * 1000
		strtahun = str(inttahun)
	else:
		jadi = True
print(inttahun)


s = input()
for i in range(int(s) + 1, 90000):
	a = str(i)
	if len(set(a)) == len(a):
		print(a)
		break


def check(yr):
	if len(set(yr)) != len(yr):
		return 0
	return 1
yr = input()
n = int(yr)
n += 1
yr = str(n)
while check(yr) != 1:
	n = int(yr)
	n += 1
	yr = str(n)
print(n)


n = int(input()) + 1
s = str(n)
while len(s) != len(set(s)):
	n += 1
	s = str(n)
print(s)


import sys
year = int(input())
status = True
while status:
	year += 1
	if len(set(map(int, str(year)))) > 3:
		status = False
print(year)


y_string = input()
y = int(y_string)
y += 1
while True:
	if len(set(str(y))) != len(str(y)):
		if y_string[0] == y_string[1]:
			y += 100
			y_string = list(str(y))
			y_string[2] = y_string[3] = '0'
			y = int(''.join(y_string))
		elif y_string[1] == y_string[2]:
			y += 10
			y_string = list(str(y))
			y_string[3] = '0'
			y = int(''.join(y_string))
		else:
			y += 1
	else:
		print(y)
		break


import math
base = int(input())
for i in range(base + 1, 9999):
	a = math.floor(i / 1000)
	b = math.floor((i - 1000 * a) / 100)
	c = math.floor((i - 1000 * a - 100 * b) / 10)
	d = i - 1000 * a - 100 * b - 10 * c
	lst = [a, b, c, d]
	if len(set(lst)) == 4:
		year = i
		break
	else:
		continue
print(int(year))


year = int(input())

def distinct(n):
	N = list(str(n))
	if any([N.count(i) > 1 for i in list('0123456789')]):
		return False
	else:
		return True
while True:
	year += 1
	if distinct(year) is True:
		break
print(year)


year = int(input()) + 1

def isbeauty(year):
	nyear = str(year)
	nyear = sorted(nyear)
	return nyear[0] != nyear[1] != nyear[2] != nyear[3]
while True:
	if isbeauty(year):
		break
	year += 1
print(year)


ok = lambda x: len(x) == len(set(x))
n = int(input()) + 1
while not ok(str(n)):
	n += 1
print(n)


year = int(input()) + 1
yearStr = str(year)
while yearStr[0] == yearStr[1] or yearStr[1] == yearStr[2] or yearStr[2] == yearStr[3] or (yearStr[0] == yearStr[2]) or (yearStr[1] == yearStr[3]) or (yearStr[0] == yearStr[3]):
	year += 1
	yearStr = str(year)
print(year)


y = int(input())
y += 1
a = str(y)
b = set(a)
while len(b) == 2 or len(b) == 3 or len(b) == 1:
	y += 1
	a = str(y)
	b = set(a)
print(y)


k = int(input())
y = k
while True:
	y = str(y + 1)
	for x in range(3):
		if y[x] in y[x + 1:]:
			break
		if x == 2:
			print(y)
			exit(0)
	y = int(y)


def year(n):
	c = 0
	s = str(n)
	for i in s:
		x = s.count(i)
		if x == 1:
			c += 1
	if c == 4:
		print(n)
	else:
		year(n + 1)
n = int(input())
r = 0
r = year(n + 1)


n = int(input())

def year(n):
	lst = []
	for i in range(4):
		lst.append(int(n % 10))
		n = n / 10
	for i in range(4):
		a = lst[i]
		for j in range(4):
			if a == lst[j] and i != j:
				return False
	return True
out = False
while not out:
	n = n + 1
	out = year(n)
print(n)


y = int(input())
a = y + 1
for i in range(a, 9013):
	if len(set(str(i))) == 4:
		o = i
		break
print(o)


n = int(input())
c = 0
n = n + 1
while c == 0:
	a = n
	n = str(n)
	n = list(n)
	if len(set(n)) == len(n):
		c = c + 1
		print(a)
	else:
		n = int(''.join(n))
		n = n + 1


n = input()
m = int(n)
x = m + 1
while x > m:
	if str(x).count(str(x)[0]) == 1 and str(x).count(str(x)[1]) == 1 and (str(x).count(str(x)[2]) == 1) and (str(x).count(str(x)[3]) == 1):
		print(x)
		break
	elif str(x).count(str(x)[0]) > 1 or str(x).count(str(x)[1]) > 1 or str(x).count(str(x)[2]) > 1 or (str(x).count(str(x)[3]) > 1):
		x += 1


x = int(input())
for i in range(x + 1, 9000):
	p = str(i)
	q = set(list(p))
	if len(p) == len(q):
		print(p)
		break
	else:
		continue
if x > 8976:
	print('9012')


n = int(input())
k = 0
while k == 0:
	p = str(n + 1)
	l = list(p)
	s = set(l)
	if len(s) == len(l):
		print(p)
		k = 1
	else:
		n += 1


y = int(input())
while True:
	y += 1
	if y < 9999:
		if len(set(str(y))) == 4:
			break
	elif len(set(str(y))) == 5:
		break
print(y)


def beautiful_year(year):
	count = 0
	temp = year + 1
	while count == 0:
		if len(set(str(temp))) == len(str(year)):
			count = 1
			print(temp)
		temp += 1
year = int(input())
beautiful_year(year)


def func(n):
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	d = n // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return 1
	else:
		return 0
n = int(input())
for i in range(n + 1, 9013):
	x = func(i)
	if x == 1:
		print(i)
		break


a = int(input())
while True:
	a += 1
	b = str(a)
	past = []
	for i in b:
		if i not in past:
			past.append(i)
	count = len(past)
	if count == 4:
		print(a)
		break


def is_distinct(x):
	numbers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while x > 0:
		numbers[x % 10] += 1
		x = x // 10
	return all((x < 2 for x in numbers))
year = int(input())
while True:
	year += 1
	if is_distinct(year) == True:
		print(year)
		break


a = int(input())
b = True
while b:
	a = str(int(a) + 1)
	c = [0] * 10
	for i in range(len(a)):
		c[int(a[i])] += 1

	def BY(a):
		for i in range(10):
			if c[i] > 1:
				return True
		return False
	b = BY(a)
print(a)


s = str(input())
k = int(s)
i = k + 1
while True:
	if len(set(str(i))) == len(s):
		print(i)
		break
	i += 1


a = int(input())
i = 1
x = set()
while True:
	s = str(a + i)
	x = set(list(s))
	if len(x) == len(s):
		print(s)
		break
	i += 1


year = int(input())

def areDigitsDistinct(number):
	digits = []
	while number // 10 != 0:
		digits.append(number % 10)
		number = number // 10
	if number // 10 == 0:
		digits.append(number)
	for i in range(len(digits)):
		for j in range(i + 1, len(digits)):
			if digits[i] == digits[j]:
				return False
			else:
				continue
	return True
startYear = year + 1
while areDigitsDistinct(startYear) != True:
	startYear = startYear + 1
print(startYear)


y = input()
list1 = []
for e in y:
	list1.append(e)
s = set([])
while len(s) != len(list1):
	list1.clear()
	y = int(y) + 1
	y = str(y)
	for i in y:
		list1.append(i)
	s = set(list1)
	b = len(s)
	a = len(list1)
print(y)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
year = int(input())
while year <= 9000:
	year += 1
	if len(set(str(year))) == 4:
		break
if year - 1 == 9000:
	print(9012)
else:
	print(year)


a = int(input())
c = a + 1
while True:
	if c > a and len(set(str(c))) == 4:
		break
	else:
		c += 1
print(c)


b = int(input())
b = b + 1
a = str(b)
for i in range(9000):
	l = list(a)
	if l[1] != l[2] and l[1] != l[2] and (l[1] != l[3]) and (l[1] != l[0]) and (l[2] != l[3]) and (l[2] != l[0]) and (l[3] != l[0]):
		c = ''.join(l)
		break
	else:
		e = int(a)
		b = e + 1
		a = str(b)
print(c)


y = int(input())
y += 1
s = str(y)
a_set = set()
for c in s:
	a_set.add(c)
while len(a_set) != 4:
	y += 1
	s = str(y)
	a_set = set()
	for c in s:
		a_set.add(c)
print(y)


import sys
y = int(input())
if len(set(str(y))) == 4:
	y += 1
if len(set(str(y))) == 4:
	print(y)
	sys.exit()
while len(set(str(y))) != 4:
	y += 1
print(y)


def year(numb):
	for i in range(int(numb) + 1, 9100):
		nub = list(str(i))
		dic = dict.fromkeys(nub, 0)
		for item in nub:
			dic[item] += 1
		lis = []
		for (a, b) in dic.items():
			lis.append(b)
		if len(lis) == 4:
			return ''.join(nub)
a = input()
print(year(a))


num = int(input())
flag = 0
while True:
	num = num + 1
	strnum = str(num)
	for i in range(len(strnum)):
		if strnum[i] in strnum[0:i] + strnum[i + 1:]:
			flag = 2
			break
		else:
			flag = 1
	if flag == 2:
		continue
	if flag == 1:
		break
print(num)


n = int(input())
n = n + 1
while True:
	d = {}
	a = 0
	for i in str(n):
		if i not in d:
			d[i] = 1
		else:
			a = 1
			break
	if a == 1:
		n += 1
	else:
		print(n)
		break


inp = input()
for i in range(int(inp) + 1, 10000):
	str1 = str(i)
	l1 = []
	for j in str1:
		if j not in l1:
			l1.append(j)
	if len(str1) == len(l1):
		print(str1)
		break


y = int(input())
y += 1
x = [int(i) for i in str(y)]
for j in range(8000):
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		x = [str(i) for i in x]
		print(''.join(x))
		break
	else:
		y += 1
		x = [int(i) for i in str(y)]


n = int(input())
while True:
	n += 1
	if not str(n)[0] in str(n)[1:] and (not str(n)[1] in str(n)[0] + str(n)[2:]) and (not str(n)[2] in str(n)[:2] + str(n)[3]):
		print(n)
		quit()


a = int(input())
while True:
	a += 1
	t = True
	for i in str(a):
		if str(a).count(i) > 1:
			t = False
	if t is True:
		print(a)
		exit()


s = input()
sn = int(s)
while True:
	sn += 1
	temp = str(sn)
	f = 0
	for i in range(len(temp) - 1):
		if temp[i] in temp[i + 1:]:
			f = 1
			break
	if f == 0:
		break
ans = str(sn)
print(ans)


import sys
import math
n = str(int(input()) + 1)

def unique(n, pole):
	pole = list(n)
	for i in range(len(pole)):
		pom = pole.count(pole[i])
		if i == len(pole) - 1:
			print(n)
			break
		if pom > 1:
			unique(str(int(n) + 1), 0)
			break
unique(n, 0)


a = str(int(input()) + 1)

def digit(a):
	for i in a:
		if a.count(i) > 1:
			a = str(int(a) + 1)
			break
		else:
			pass
	return a
while digit(a) > a:
	a = digit(a)
print(a)


a = int(input())
for i in range(a + 1, 10000):
	b = i % 10
	c = i // 10
	d = c % 10
	e = c // 10
	f = e % 10
	g = e // 10
	r = g % 10
	if f != b != d != f != r != b != r != d:
		print(i)
		break


def different(n):
	s = str(n)
	L = list(s)
	K = set(s)
	if len(K) == len(L):
		return True
	else:
		return False
n = int(input())
n = n + 1
while not different(n):
	n += 1
print(n)


year = int(input())
found = False
while not found:
	year += 1
	digits = []
	for c in str(year):
		if not c in digits:
			digits.append(c)
	if len(digits) >= 4:
		found = True
print(year)


lower = input()
i = str(int(lower) + 1)
while True:
	a = i[0]
	b = i[1]
	c = i[2]
	d = i[3]
	digits = [a, b, c, d]
	unique = set(digits)
	if len(unique) == len(digits):
		break
	i = str(int(i) + 1)
print(i)


a = int(input())
b = ''
i = 8976
for i in range(a + 1, 9013):
	b = str(i)
	if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
		break
print(i)


n = int(input())
k = n
while True:
	k += 1
	if k // 1000 != k // 100 % 10 and k // 1000 != k % 100 // 10 and (k // 1000 != k % 10):
		if k // 100 % 10 != k % 100 // 10 and k // 100 % 10 != k % 10:
			if k % 100 // 10 != k % 10:
				print(k)
				break


def number(year):
	y = year // 1000
	e = year // 100 % 10
	a = year // 10 % 10
	r = year % 10
	if len({y, e, a, r}) == 4:
		print(year)
		return True
	else:
		return False
year = int(input())
a = False
while a == False:
	year += 1
	a = number(year)


y = int(input())
sett = set()
for i in range(1, 1000):
	x = y + i
	s = str(x)
	sett = 0
	sett = set()
	for j in range(0, len(s)):
		sett.add(s[j])
		if len(sett) == len(s):
			print(x)
			break
	if len(sett) == len(s):
		break


s = int(input())
c = 0
while c == 0:
	s += 1
	t = str(s)
	j = []
	for i in t:
		if i not in j:
			j.append(i)
	if len(j) == 4:
		c = 1
		print(s)
		break


year_number = int(input())
a = year_number
answer = 0
a += 1
y = 0
while answer == 0:
	b = str(a)
	if b[0] != b[1] != b[2] != b[3]:
		if b[1] != b[3] != b[0] != b[2]:
			answer += a
	a += 1
	y += 1
print(answer)


def has_dist_numbers(num):
	dist = ''
	for number in str(num):
		if number not in dist:
			dist += number
	if int(dist) == num:
		return True
	return False
y = int(input())
dy = y + 1
while not has_dist_numbers(dy):
	dy += 1
print(dy)


a = int(input())
i = a + 1
u = i
while int(u) >= a and i <= 9999:
	u = str(i)
	f = list(u)
	x = f.count(f[0])
	y = f.count(f[1])
	z = f.count(f[2])
	i = i + 1
	if x == 1 and y == 1 and (z == 1):
		print(u)
		break


n = int(input())
a = []
for i in range(n + 1, 9999):
	digit1 = i // 1000
	digit2 = i % 1000 // 100
	digit3 = i % 100 // 10
	digit4 = i % 10
	if digit1 != digit2 and digit1 != digit3 and (digit1 != digit4) and (digit2 != digit3) and (digit2 != digit4) and (digit3 != digit4):
		print(i)
		break


year = int(input())

def distinct_digit(year):
	digit = []
	while year != 0:
		if year % 10 not in digit:
			digit.append(year % 10)
		else:
			return False
		year = int(year / 10)
	return True
while True:
	year = year + 1
	if distinct_digit(year) == True:
		print(year)
		break


def check(year):
	s = set(str(year))
	return len(s) == 4
n = int(input())
for i in range(9000):
	n += 1
	if check(n):
		print(n)
		break


n = int(input())
n += 1
m = True
while True:
	x = []
	for i in str(n):
		if i in x:
			m = False
			break
		else:
			m = True
			x += [i]
	if m:
		print(n)
		break
	n += 1


def new(a):
	for _ in range(1000, 9001):
		a = int(a) + 1
		b = list(str(a).strip())
		if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
			return a
a = str(input())
print(new(a))


def num_to_list(num):
	l = []
	while num > 0:
		l.append(num % 10)
		num = num // 10
	return l
year = int(input())
year += 1
while len(set(num_to_list(year))) < 4:
	year += 1
print(year)


er = input()
while 1:
	er = str(int(er) + 1)
	if len(set(er)) == 4:
		print(er)
		break


y = int(input())
beautiful = False
while not beautiful:
	y += 1
	year = str(y)
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]) and (year[1] != year[2]) and (year[1] != year[3]) and (year[2] != year[3]):
		beautiful = True
print(y)


y = int(input())
cnt = 0
my_list = []
while len(my_list) < 4:
	y += 1
	new_year = y
	while new_year:
		rem = int(new_year % 10)
		if rem in my_list:
			my_list = []
			break
		else:
			my_list.append(rem)
		new_year = int(new_year / 10)
rev_list = my_list[::-1]
for s in rev_list:
	print(s, end='')


import sys
n = int(sys.stdin.readline().strip())
while n > 0:
	n += 1
	if len(set(list(str(n)))) == len(str(n)):
		print(n)
		break


year = int(input(''))
status = True
while status:
	year += 1
	if len(set(str(year))) == 4:
		status = False
print(year)


b = int(input()) + 1
a = str(b)
n = len(a)
while 1:
	k = 1
	for i in range(n - 1):
		if a[i] in a[i + 1:]:
			k = 0
			break
	if k:
		print(a)
		exit()
	else:
		b += 1
		a = str(b)


y = input()
z = int(y)
a = True
while a:
	z += 1
	y = str(z)
	c = []
	for q in y:
		if q not in c:
			c.append(q)
	if len(y) == len(c):
		print(y)
		a = False
	else:
		a = True


n = int(input())
c = n + 1
while c > n:
	s = str(c)
	li = list(s)
	se = set(li)
	if len(se) == len(li):
		break
	else:
		c = c + 1
print(c)


jaar = int(input())

def uniek(x):
	enig = True
	for i in range(0, 4):
		for j in range(i + 1, 4):
			if x[i] == x[j]:
				enig = False
				break
	if enig == True:
		return True
	else:
		return False
for i in range(jaar + 1, 9999):
	if uniek(str(i)) == True:
		print(i)
		break


def fd70000000():
	s = int(input()) + 1
	while True:
		if len(set(str(s))) != len(str(s)):
			s += 1
		else:
			return print(s)
fd70000000()


n = int(input())
r = ''
sw = True
sw1 = False
n += 1
while sw:
	sw1 = False
	for x in str(n):
		if str(n).count(x) > 1:
			n += 1
			sw1 = True
			break
	if not sw1:
		print(n)
		sw = False


year = input()
year = str(int(year) + 1)
distin_fig = [digit for digit in year]
distin_fig = set(distin_fig)
distin_fig = list(distin_fig)
distin_fig = len(distin_fig)
while distin_fig != 4:
	year = str(int(year) + 1)
	distin_fig = [digit for digit in year]
	distin_fig = set(distin_fig)
	distin_fig = list(distin_fig)
	distin_fig = len(distin_fig)
print(year)


test = int(input())
while True:
	dic = {}
	test += 1
	num = test
	lista = list(str(test))
	firstdigit = lista[0]
	dic.update({firstdigit: True})
	if lista[1] in dic:
		continue
	else:
		dic.update({lista[1]: True})
		if lista[2] in dic:
			continue
		else:
			dic.update({lista[2]: True})
			if lista[3] in dic:
				continue
			else:
				break
print(num)


year = input()
iyear = int(year) + 1
while len(set(str(iyear))) < len(str(iyear)):
	iyear += 1
print(iyear)


year = input()
current_year = int(year) + 1
while True:
	distinct_digits = True
	str_year = str(current_year)
	for letter in str_year:
		if str_year.count(letter) > 1:
			distinct_digits = False
			break
	if distinct_digits:
		print(current_year)
		break
	else:
		current_year += 1


def func(y):
	s = str(y)
	return s.count(s[0]) == s.count(s[1]) == s.count(s[2]) == s.count(s[3]) == 1
n = int(input())
y = n + 1
while func(y) == False:
	y += 1
print(y)


n = int(input())
n = n + 1

def is_good(x):
	x = list(str(x))
	for i in range(len(x) - 1):
		for g in range(i + 1, len(x)):
			if x[i] == x[g]:
				return False
	return True
while not is_good(n):
	n = n + 1
print(n)


def check(year):
	arr = []
	year = str(year)
	for y in year:
		if y not in arr:
			arr.append(y)
	if len(arr) == 4:
		return True
	else:
		return False
from sys import stdin
year = int(stdin.readline())
year += 1
while not check(year):
	year += 1
print(year)


t = int(input())
t += 1
q = 1
while q != 0:
	p = set(str(t))
	if len(p) == len(str(t)):
		q = 0
	else:
		t += 1
print(t)


year = int(input())
lis = [str(x) for x in str(year)]
beau = 0
for i in range(year + 1, 10000):
	temLis = []
	temLis = [str(x) for x in str(i)]
	tem_set = set(temLis)
	if len(tem_set) == 4:
		beau = i
		break
print(i)


import copy
x = int(input())
y = copy.deepcopy(x)
while x <= 9012:
	val = []
	p = copy.deepcopy(x)
	while p > 0:
		temp = p % 10
		val.append(temp)
		p = p // 10
	count = 0
	temp1 = 0
	for value in val:
		temp1 = temp1 + 10 ** count * int(value)
		count += 1
	if len(set(val)) >= 4 and temp1 > y:
		print(temp1)
		break
	x += 1


n = int(input())
for i in range(1, 8000):
	s = str(n + i)
	if s.count(s[0]) > 1 or s.count(s[1]) > 1 or s.count(s[2]) > 1 or (s.count(s[3]) > 1):
		i += 1
	else:
		print(s)
		break


a = int(input()) + 1
while len(set([str(a)[0], str(a)[1], str(a)[2], str(a)[3]])) != 4:
	a += 1
print(a)


from sys import stdin
y = int(stdin.readline().strip())
for i in range(y + 1, 9999):
	if len(set(str(i))) == 4:
		print(i)
		exit()


n = int(input())
for i in range(n + 1, 9124):
	if all([str(i).count(x) == 1 for x in str(i)]):
		print(i)
		break


y = int(input()) + 1
while True:
	if len(set((i for i in str(y)))) > 3:
		print(y)
		break
	else:
		y += 1


n = input()
n2 = int(n)
n2 += 1
n = str(n2)
a = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
while a[0] == a[1] or a[0] == a[2] or a[0] == a[3] or (a[1] == a[2]) or (a[1] == a[3]) or (a[2] == a[3]):
	n2 = int(n)
	n2 += 1
	n = str(n2)
	a = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
print(n)


otv = int(input())
flag = True
n = otv
while flag:
	if n % 10 != n // 1000 and n % 10 != n // 10 % 10 and (n % 10 != n // 100 % 10) and (n // 10 % 10 != n // 100 % 10) and (n // 10 % 10 != n // 1000) and (n // 100 % 10 != n // 1000) and (n > otv):
		print(n)
		flag = False
	else:
		n += 1


year = int(input())
ans = year + 1
while True:
	years = str(ans)
	if years[0] != years[1] and years[0] != years[2] and (years[0] != years[3]) and (years[1] != years[2]) and (years[3] != years[2]) and (years[1] != years[3]):
		break
	else:
		ans += 1
print(ans)


def split(p):
	return [int(i) for i in str(p)]

def saoDif(l):
	numeros = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
	res = split(l)
	pos = 0
	tamRes = len(res)
	while len(numeros) > 0 and pos < tamRes:
		if res[pos] in numeros:
			numeros.remove(res[pos])
		else:
			return -1
		pos += 1
	return 1

def encontreDif(l, r):
	for i in range(l + 1, r):
		if saoDif(i) == 1:
			return i
	return -1
l = int(input())
l += 1
if saoDif(l) == 1:
	print(l)
else:
	aux = encontreDif(l, 9013)
	print(aux)


def find(ins):
	ins += 1
	test = [int(i) for i in str(ins)]
	inlist = []
	for i in test:
		if i in inlist:
			test = find(ins)
			break
		else:
			inlist.append(i)
	return ''.join((str(x) for x in test))
ins = int(input())
print(find(ins))


def func(a, m):
	b = set(str(a))
	if len(b) is len(list(str(m))):
		return True
	else:
		return False
n = input()
m = int(n)
for i in range(m + 1, 11000):
	if func(i, m):
		print(i)
		break


def solution(y):
	y = int(y) + 1
	while len(set(str(y))) != 4:
		y = int(y) + 1
	return int(y)

def main():
	year = input()
	print(solution(year))
main()


def b(y):
	while True:
		y = str(int(y) + 1)
		if len(set(y)) == 4:
			return y
n = int(input())
print(b(n))


def solve(a):
	while True:
		a = str(int(a) + 1)
		if len(set(a)) == 4:
			return a
print(solve(input()))


y = int(input())

def dist(x):
	x1 = x % 10
	x = int(x / 10)
	x2 = x % 10
	x = int(x / 10)
	x3 = x % 10
	x = int(x / 10)
	x4 = x % 10
	x = int(x / 10)
	if x1 != x2 and x2 != x3 and (x3 != x4) and (x4 != x1) and (x2 != x4) and (x1 != x3):
		return True
	else:
		return False
while True:
	y += 1
	if dist(y):
		print(y)
		break


y = int(input()) + 1
while not len(set(list(str(y)))) == len(list(str(y))):
	y += 1
print(y)


n = input()
s = int(n) + 1
n = str(s)
while True:
	p = set(n)
	if len(p) == 4:
		break
	else:
		s = int(n) + 1
		n = str(s)
print(n)


a = int(input())
for i in range(a + 1, a + 1000):
	j = str(i)
	w = j[0]
	x = j[1]
	y = j[2]
	z = j[3]
	if j.count(w) == j.count(x) == j.count(y) == j.count(z) == 1:
		print(i)
		break
	else:
		pass


y = input()
y = str(int(y) + 1)
while True:
	y1 = ''
	for i in y:
		if i not in y1:
			y1 = y1 + i
	if int(y) == int(y1):
		print(y)
		break
	else:
		y = str(int(y) + 1)


year = int(input())
while True:
	flag = 0
	year += 1
	for i in range(0, 10):
		if str(year).count(str(i)) > 1:
			flag = 1
			break
	if not flag:
		print(year)
		break


a = int(input())
s = a + 1
d = s % 10
f = s // 10 % 10
g = s // 100 % 10
h = s // 1000
while d == f or d == g or d == h or (f == g) or (f == h) or (g == h):
	s = s + 1
	d = s % 10
	f = s // 10 % 10
	g = s // 100 % 10
	h = s // 1000
print(s)


n = input()
l = len(n)
n1 = str(int(n) + 1)
while not len(n1) == len(set(n1)):
	n1 = str(int(n1) + 1)
print(n1)


y = int(input())
while True:
	y += 1
	Y = str(y)
	s = set()
	for e in Y:
		s.add(e)
	if len(s) == len(Y):
		break
print(y)


y = input()
x = int(y) + 1
while 1:
	w = str(x)
	if w[0] != w[1] and w[0] != w[2] and (w[2] != w[1]) and (w[2] != w[3]) and (w[0] != w[3]) and (w[1] != w[3]):
		print(x)
		break
	else:
		x += 1
		continue


f = int(input())
for i in range(f + 1, 9999999):
	i = str(i)
	d = 0
	m = 0
	for j in range(len(i)):
		if i.count(i[j]) != 1:
			m = 1
			break
		d = i[j]
	if m == 0:
		print(i)
		break
	i = int(i)


input = int(input(''))

def unique(year):
	a = year % 10
	b = year // 10 % 10
	c = year // 100 % 10
	d = year // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return True
	else:
		return False
for i in range(input + 1, 9020):
	if unique(int(i)):
		print(i)
		break


def checkYear(n):
	s = str(n)
	l = []
	for i in s:
		if i not in l:
			l.append(i)
	if len(l) == len(s):
		print(s)
		return 1
	return 0
n = int(input())
n += 1
while True:
	if checkYear(n) == 1:
		break
	else:
		n += 1


def check(year):
	year = str(year)
	if year.count(year[0]) == 1 and year.count(year[1]) == 1 and (year.count(year[2]) == 1) and (year.count(year[3]) == 1):
		return True
	else:
		return False

def main():
	s = input()
	for i in range(int(s) + 1, 9999999, 1):
		if check(i):
			print(i)
			break
main()


n = int(input())
n = n + 1
while 1:
	s = ''
	n = str(n)
	for i in n:
		if i not in s:
			s = s + i
		else:
			n = str(int(n) + 1)
			break
	else:
		print(n)
		break


def distinct_listo(n):
	stevilo = str(n)
	listi = []
	for i in stevilo:
		if i not in listi:
			listi.append(i)
		else:
			return False
	return n
x = int(input()) + 1

def najdi_naslednjika(x):
	while distinct_listo(x) == False:
		x += 1
	return x
print(najdi_naslednjika(x))


a = int(input())
while 1:
	a = a + 1
	s = str(a)
	b = list(s)
	x = set(b)
	l1 = len(b)
	l2 = len(x)
	if l1 == l2:
		print(a)
		break


n = int(input())
for i in range(n):
	n = n + 1
	y = n
	a = y % 10
	y = y // 10
	b = y % 10
	y = y // 10
	c = y % 10
	y = y // 10
	d = y
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(d, end='')
		print(c, end='')
		print(b, end='')
		print(a)
		break


y = int(input())
y += 1
while y < 10000:
	a = str(y)
	b = list(a)
	if len(set(b)) == 4:
		print(y)
		exit()
	else:
		y += 1


for x in range(int(input()) + 1, 2147483647):
	if len(set(str(x))) == len(list(str(x))):
		print(x)
		break


first_year = input()
next_year = int(first_year)
num = 0
while True:
	next_year += 1
	for i in range(4):
		next_year = str(next_year)
		if first_year[i] == next_year[i]:
			break
		else:
			num += 1
	if len(set(next_year)) == 4:
		print(next_year)
		break
	else:
		num = 0
		next_year = int(next_year)


n = int(input())
flag = 1
while flag:
	n += 1
	x = n
	A = set(map(int, str(n)))
	if len(A) == 4:
		flag = 0
		break
print(x)


n = int(input())
for i in range(n + 1, 10000):
	a = []
	for j in str(i):
		a.append(j)
	s = list(set(a))
	if len(a) == len(s):
		break
print(i)


def beautifulYear():
	n = int(input())
	current = n
	while True:
		if len(set(str(n))) == len(str(n)) and n != current:
			print(n)
			break
		else:
			n += 1
beautifulYear()


def mods(a, x):
	a.append(x % 10)
	x //= 10
	return x

def func(n):
	global flag
	(m, x, a) = (0, n, [])
	for i in range(4):
		x = mods(a, x)
	for i in a:
		if a.count(i) >= 2:
			break
		else:
			m += 1
	if m == 4:
		flag = False
		return n
	n += 1
	return n
(n, flag) = (int(input()), True)
x = n + 1
while flag:
	x = func(x)
print(x)


g = int(input())
gf = ''
for i in range(g + 1, 10000):
	gs = str(i)
	if len(set(gs)) == 4:
		gf = gs
		break
print(gf)


y = int(input())
s = str(y + 1)
a = s[0]
b = s[1]
c = s[2]
d = s[3]
if s.count(a) == 1 and s.count(b) == 1 and (s.count(c) == 1) and (s.count(d) == 1):
	print(y + 1)
else:
	for i in range(10 ** 4):
		y = y + 1
		s = str(y)
		a = s[0]
		b = s[1]
		c = s[2]
		d = s[3]
		if s.count(a) == 1 and s.count(b) == 1 and (s.count(c) == 1) and (s.count(d) == 1):
			print(y)
			break


t = list(input())
t = int(''.join(t))
t += 1
t = list(str(t))
while t[0] == t[1] or t[0] == t[2] or t[0] == t[3] or (t[1] == t[2]) or (t[1] == t[3]) or (t[2] == t[3]):
	t = int(''.join(t))
	t += 1
	t = list(str(t))
print(''.join(t))


def ist(x):
	x = str(x)
	s = set()
	for i in x:
		s.add(i)
	if len(s) == 4:
		return 1
	return 0
n = int(input())
while 1:
	n = n + 1
	if ist(n) == 1:
		print(n)
		break


s = int(input())
i = s + 1
while True:
	if len(str(i)) == len(set(str(i))):
		print(i)
		exit()
	i += 1


n = int(input())
for i in range(n + 1, 900000000001):
	str1 = str(i)
	li = set(str1)
	if len(li) == 4:
		print(i)
		break


n = int(input())
a = int(n)
while a >= n:
	a += 1
	if sorted(set(str(a))) == sorted(str(a)):
		print(a)
		break
	else:
		pass


n = int(input())

def difNum(n):
	a = set()
	while len(a) != 4:
		n += 1
		a = set(str(n))
	return n
print(difNum(n))


def check_if_beautiful(year_number):
	year_number_as_string = str(year_number)
	bucket = {}
	for digit in year_number_as_string:
		if digit in bucket:
			return False
		bucket[digit] = 0
	return True

def find_next_beautiful_number(year_number):
	while True:
		year_number += 1
		if check_if_beautiful(year_number):
			return year_number
year_number = int(input())
print(find_next_beautiful_number(year_number))


fyear = int(input()) + 1

def jud(x):
	k = []
	xxx = list(str(x))
	for y in xxx:
		a = xxx.count(y)
		k.append(a)
	if k == [1, 1, 1, 1]:
		return False
	else:
		return True
while jud(fyear):
	fyear += 1
print(fyear)


n = int(input())
n = n + 1
while n // 1000 == n // 100 % 10 or n // 1000 == n // 10 % 10 or n // 1000 == n % 10 or (n // 100 % 10 == n // 10 % 10) or (n // 100 % 10 == n % 10) or (n // 10 % 10 == n % 10):
	n = n + 1
print(n)


n = int(input())
count = 0
while count == 0:
	n = str(n + 1)
	count1 = 1
	for i in range(4):
		for j in range(i + 1, 4):
			if n[i] != n[j]:
				pass
			else:
				count1 = 0
				break
	if count1 == 1:
		print(n)
		count = 1
		break
	else:
		n = int(n)


n = int(input())
while True:
	n += 1
	m = str(n)
	if len(set(m)) == len(m):
		print(n)
		exit()


number = input()

def beautiful(num):
	for i in range(0, len(num) - 1):
		for j in range(i + 1, len(num)):
			if num[i] == num[j]:
				return False
	return True
number = int(number) + 1
while not beautiful(str(number)):
	number += 1
print(number)


n = int(input())

def check(n):
	k = str(n)
	x = set()
	for i in k:
		x.add(i)
	if len(x) == 4:
		return True
	else:
		return False
while 1:
	n += 1
	if check(n):
		print(n)
		break


n = int(input())
for i in range(n + 1, 9013):
	c = []
	f = 0
	tp = str(i)
	c.append(tp[0])
	for j in range(1, 4):
		for k in c:
			if tp[j] == k:
				f = -1
				break
		if f == -1:
			break
		else:
			c.append(tp[j])
			f = 0
			continue
	if f == -1:
		continue
	else:
		print(i)
		break


s = int(input())

def my(y):
	r = []
	for i in str(y):
		r.append(i)
	if len(set(r)) == len(str(y)):
		return False
	return True
while True:
	s = s + 1
	if my(s):
		continue
	else:
		break
print(s)


def isdistinct(instr):
	temp = list(instr)
	for i in temp:
		if temp.count(i) > 1:
			return False
		else:
			pass
	return True
inp = input()
z = int(inp) + 1
while isdistinct(str(z)) == False:
	if isdistinct(str(z)):
		break
	z += 1
print(z)


y = int(input())
for i in range(y + 1, 90124):
	y1 = list(str(i))
	y1.sort()
	y2 = list(set(y1))
	y2.sort()
	if y1 == y2:
		print(i)
		break


def getdic(n):
	d = {}
	while n != 0:
		digit = n % 10
		d[digit] = d.get(digit, 0) + 1
		n = n // 10
	return d
n = int(input())
flag = False
n += 1
for i in range(500):
	d = getdic(n + i)
	c = 0
	for val in d.values():
		if val == 1:
			c += 1
	if c == 4:
		print(n + i)
		break


a = int(input())
c = 1
while c > 0:
	count = 0
	a = a + 1
	s = str(a)
	seta = set(s)
	for i in seta:
		if s.count(i) > 1:
			break
		else:
			count += 1
	if count == len(s):
		c = 0
		print(a)


n = int(input())
year = n + 1
flag = 1
L = list(str(year))
x = len(L)
while flag:
	for i in range(x):
		for j in range(i + 1, x):
			if L[j] == L[i]:
				flag = 0
				break
		if flag == 0:
			break
	if flag == 1:
		print(year)
		break
	else:
		flag = 1
		year += 1
		L = list(str(year))
		x = len(L)


def uniq(i):
	a = []
	for j in str(i):
		if j not in a:
			a.append(j)
	if ''.join(a) == str(i):
		return 1
	return 0
s = int(input())
s += 1
while True:
	if uniq(s):
		print(s)
		break
	else:
		s += 1


def check(x):
	x = set(str(x))
	if len(x) == 4:
		return True
	else:
		return False
year = int(input()) + 1
while not check(year):
	year += 1
print(year)


saver = int(input())
flag = 1
while flag:
	num = saver + 1
	visited = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while num:
		if visited[int(num % 10)]:
			break
		visited[int(num % 10)] = 1
		num = int(num / 10)
	if num == 0:
		flag = 0
	else:
		saver += 1
print(saver + 1)


k = int(input()) + 1
s = str(k)
flag = True
while flag:
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		flag = False
	else:
		k += 1
	s = str(k)
print(k)


n = [int(__) for __ in list(input().strip())]
spotted = None
for i in range(len(n) - 1, -1, -1):
	num = n[i] + 1
	while num in n[:i] and num != 10:
		num += 1
	if num != 10:
		spotted = i
		n[spotted] = num
		break
for i in range(spotted + 1, len(n)):
	n[i] = i - spotted - 1
	num = n[i]
	while num in n[:i]:
		num += 1
	n[i] = num
for i in range(1, len(n)):
	if n[i] in n[:i]:
		dup = i
		num = n[i] + 1
		while num in n[:i]:
			num += 1
		n[i] = num
		for j in range(dup + 1, len(n)):
			n[j] = j - dup - 1
			num = n[j]
			while num in n[:j]:
				num += 1
			n[j] = num
		break
print(''.join([str(i) for i in n]))


def good_enough(year):
	diff_numbers = len(set(str(year)))
	return diff_numbers == len(str(year))
year = int(input()) + 1
while not good_enough(year):
	year = year + 1
print(year)


def beautiful(year):
	digitos = list(str(year))
	digitos.sort()
	for i in range(3):
		if digitos[i] == digitos[i + 1]:
			return False
	return True

def main():
	year = int(input()) + 1
	while not beautiful(year):
		year = year + 1
	print(year)
main()


__author__ = 'myduomilia'
year = int(input())
s = set()
while len(s) < 4:
	s = set()
	year += 1
	s = set('%s' % year)
print(year)


def distinct(num):
	if len(set(str(num))) == len(str(num)):
		return True
	else:
		return False
y = int(input())
y += 1
nd = True
while nd:
	if distinct(y):
		print(y)
		break
	y += 1


year = int(input())
f = 0
while f == 0:
	year += 1
	count = 0
	for i in range(4):
		for j in range(4):
			if str(year)[i] == str(year)[j]:
				count += 1
	if count == 4:
		f = 1
print(year)


y = int(input())

def unique_digit(n):
	x = [False] * 10
	for d in str(n):
		if x[int(d)]:
			return False
		else:
			x[int(d)] = True
	return True
while True:
	y += 1
	if unique_digit(y):
		break
print(y)


inp = int(input()) + 1
while len(set(str(inp))) < 4:
	inp += 1
print(inp)


n = int(input())

def check(n):
	while True:
		n += 1
		d = 0
		I = list(str(n))
		for i in range(1, 4):
			if I[i] not in I[0:i]:
				d += 1
		if d == 3:
			break
	return int(n)
print(check(n))


from collections import Counter
n = int(input())
n = n + 1
while n:
	mydict = Counter(str(n))
	d = [*mydict]
	if len(d) == 4:
		print(n)
		break
	else:
		n = n + 1


t = int(input())
n = 4

def place_1(n):
	return n % 10

def place_10(n):
	return n % 100 // 10

def place_100(n):
	return n % 1000 // 100

def place_1000(n):
	return n % 10000 // 1000
t += 1
while len(set([place_1(t), place_10(t), place_100(t), place_1000(t)])) != 4:
	t += 1
print(t)


n = [int(i) for i in input()]
n[-1] += 1
n[-2] += n[-1] // 10
n[-3] += n[-2] // 10
n[-4] += n[-3] // 10
n[-1] %= 10
n[-2] %= 10
n[-3] %= 10
while n[-1] == n[-2] or n[-3] == n[-2] or n[-1] == n[-4] or (n[-1] == n[-3]) or (n[-3] == n[-4]) or (n[-2] == n[-4]) or (n[-3] == n[-4]):
	n[-1] += 1
	n[-2] += n[-1] // 10
	n[-3] += n[-2] // 10
	n[-4] += n[-3] // 10
	n[-1] %= 10
	n[-2] %= 10
	n[-3] %= 10
print(''.join((str(i) for i in n)))


def main():
	fy = int(input()) + 1
	while len(set(str(fy))) < 4:
		fy = fy + 1
	print(fy)
main()


def fun():
	n = int(input())
	i = n + 1
	flag = True
	while flag == True:
		if len(str(i)) == len(set(str(i))):
			print(i)
			flag = False
		i += 1
fun()


n = input()

def chek(s):
	c = 0
	for i in range(len(s)):
		for j in range(len(s) - 1 - i):
			if s[i] == s[i + j + 1]:
				c += 1
	if c == 0:
		return True
	else:
		return False
b = int(n) + 1
b = str(b)
while True:
	if chek(b) == True:
		print(b)
		break
	b = str(int(b) + 1)


def main():
	y = int(input())
	while True:
		y += 1
		if len(set([i for i in str(y)])) == len(str(y)):
			print(y)
			break
main()


def beautiful_year(n):
	while True:
		n += 1
		list_n = set((letter for letter in str(n)))
		if len(list_n) == 4:
			print(n)
			break
n = int(input())
beautiful_year(n)


n = int(input())
flag = True
k = n + 1
while flag:
	s = set(str(k))
	if len(s) == 4:
		flag = False
	else:
		k += 1
print(k)


def check_distinct(year):
	return len(str(year)) == len(set(list(str(year))))
n = int(input())
for i in range(n + 1, 9013):
	if check_distinct(i):
		print(i)
		break


def get_digits_list(data):
	a = []
	while data:
		r = data % 10
		a.append(r)
		data //= 10
	a.reverse()
	return a
	pass

def all_unique_digits(digits):
	for x in digits:
		if digits.count(x) > 1:
			return False
	return True
	pass

def check_if_number_has_unique_digits(data):
	digits = get_digits_list(data)
	return all_unique_digits(digits)
	pass

def main():
	data = int(input())
	data += 1
	while True:
		if check_if_number_has_unique_digits(data):
			print(data)
			break
		data += 1
	pass
main()


from sys import stdin
_input = stdin.readline
(_set, _len, _int, _str) = (set, len, int, str)

def solution():
	n = _int(_input())
	n += 1
	while _len(_set(_str(n))) != 4:
		n += 1
	print(n)
solution()


n = int(input())
t1 = str(n)
f = False
for i in range(n + 1, 10000):
	t2 = str(i)
	for c in t2:
		if t2.count(c) > 1:
			f = True
			break
	if f:
		f = False
		continue
	print(i)
	break


year = input()
x = int(year)
while 1:
	x += 1
	a = int(x / 1000)
	b = int((x % 1000 - x % 100) / 100)
	c = int((x % 100 - x % 10) / 10)
	d = int(x % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(x)
		break


yr = int(input())
for i in range(yr + 1, 100000):
	i = str(i)
	if i[0] != i[1] and i[1] != i[2] and (i[2] != i[3]) and (i[0] != i[3]) and (i[0] != i[2]) and (i[3] != i[1]):
		print(i)
		break


y = int(input())
not_ = True
while not_:
	y += 1
	y_str = str(y)
	not_ = len(str(y_str)) > len(set(y_str))
print(y)


n = int(input())

def is_distinct(k):
	valid = True
	num = 10
	cont = {}
	while num < k * 10:
		digit = int(10 * (k % num) / num)
		if digit in cont.keys():
			valid = False
		else:
			cont[digit] = True
		num = num * 10
	return valid
n += 1
while not is_distinct(n):
	n += 1
print(n)


def is_distinct(a):
	a = str(a)
	cnt = []
	for i in range(10):
		cnt.append(0)
	a = list(a)
	for i in range(len(a)):
		x = a[i]
		x = int(x)
		cnt[x] = cnt[x] + 1
		if cnt[x] == 2:
			return False
	return True
a = int(input())
while True:
	a = a + 1
	if is_distinct(a) == True:
		print(a)
		break


def check(n):
	s = str(n)
	li = [0 for i in range(10)]
	for i in range(4):
		li[int(s[i])] = li[int(s[i])] + 1
		if li[int(s[i])] >= 2:
			return False
	return True
n = int(input())
fl = 1
while fl == 1:
	n = n + 1
	if check(n):
		print(n)
		fl = 0
		break
	else:
		continue


beau_year = int(input()) + 1
while len(set(str(beau_year))) != 4:
	beau_year += 1
print(beau_year)


def main():
	entrega = 0
	es = False
	recibe = int(input())
	i = 0
	while not es:
		recibe += 1
		entrega = recibe
		es = True
		entrega = str(entrega)
		for i in range(len(entrega)):
			for j in range(i + 1, len(entrega)):
				if entrega[i] == entrega[j]:
					es = False
	print(entrega)
	return entrega
main()


def helper(s):
	i = 0
	j = i + 1
	while i < len(s) - 1:
		while j < len(s):
			if s[i] == s[j]:
				return 0
			else:
				j = j + 1
		i = i + 1
		j = i + 1
	return 1
n = input()
num = int(n)
ans = 0
val = 0
while ans != 1:
	num = num + 1
	n = str(num)
	if helper(n) == 1:
		ans = 1
		val = num
print(val)


s = input()
s = int(s) + 1
s = str(s)
i = int(s)
while True:
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		break
	else:
		s = int(s) + 1
		s = str(s)


s = input()
i = 0
s = int(s) + 1
s = str(s)
while i < 1000:
	for i in range(4):
		e = s.count(s[0])
		f = s.count(s[1])
		g = s.count(s[2])
		h = s.count(s[3])
	if e >= 2 or f >= 2 or g >= 2 or (h >= 2):
		s = int(s) + 1
		s = str(s)
	else:
		break
print(s)


s = input().strip()
n = int(s) + 1
s = str(n)
fl = True
while fl:
	fl = False
	s = str(n)
	p = int(1000)
	a = []
	for x in s:
		if x in a:
			n += p
			n = n // p * p
			fl = True
			break
		else:
			a.append(x)
		p //= 10
print(n)


n = int(input())
a = [x for x in range(1000, 9877) if sorted(set(str(x))) == sorted(str(x))]
s = [x for x in a if x > n]
print(s[0])


l = [str(i) for i in input()]

def _tostr(l):
	s = ''
	for i in l:
		s = s + str(i)
	return s

def _tolist(s):
	l = []
	for i in s:
		l.append(i)
	return l
i = int(_tostr(l))
while True:
	i = i + 1
	l = _tolist(str(i))
	if len(l) == len({*l}):
		print(int(_tostr(l)))
		break


l = []
for i in range(1000, 9100):
	if len(set(str(i))) == 4:
		l.append(i)
target = int(input())
for i in l:
	if i > target:
		ans = i
		break
print(ans)


y = int(input())
found = False
result = y + 1
while not found:
	result_string = str(result)
	letters = set()
	for i in range(len(result_string)):
		letters.add(result_string[i])
	if len(letters) == len(result_string):
		found = True
	else:
		result += 1
print(result)


def beautyYear(x):
	n = 10000
	for i in range(x, n):
		if i > x and len(set(str(i))) == 4:
			return i
print(beautyYear(int(input())))


n = input()
a = True
number = int(n) + 1
nlen = str(number)
while a:
	if len(nlen) == len(set(nlen)):
		a = False
	else:
		number += 1
		nlen = str(number)
print(number)


a = int(input())
flag = 1
while True:
	curryr = a + flag
	yo = 0
	for i in range(4):
		if str(curryr).count(str(str(curryr)[i])) == 1:
			yo += 1
	if yo == 4:
		break
	flag += 1
print(curryr)


n = int(input())
a = [0] * 4
n = n + 1
while n < 9013:
	t = n
	for i in range(4):
		a[i] = t % 10
		t = t // 10
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		print(n)
		break
	else:
		n = n + 1


n = int(input())
a = []
l = []
s = []
for x in range(1000, 9999):
	if len(set(str(x))) == 4:
		a.append(x)
for x in a:
	if x > n:
		l.append(x)
print(min(l))


y = int(input())
y += 1
s = set([ch for ch in str(y)])
while len(s) != len(str(y)):
	y += 1
	s = set([ch for ch in str(y)])
print(y)


def decide(q):
	if len(set(str(q))) == 4:
		return True
	return False
q = int(input())
q += 1
while not decide(q):
	q += 1
print(q)


b = list(map(str, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)))
T = 1
a = int(input())
while T:
	a += 1
	for i in b:
		if str(a).count(i) >= 2:
			break
		elif i == '9':
			T = 0
print(a)


def alldif(n):
	used = []
	for i in str(n):
		if i not in used:
			used.append(i)
		else:
			return False
	return True
n = int(input())
i = n + 1
while not alldif(i):
	i += 1
print(i)


def allDiff(n):
	if len(str(n)) == len(set(str(n))):
		return True
	else:
		return False
k = int(input())
for i in range(k + 1, 90000):
	if allDiff(i):
		print(i)
		break


from sys import stdin

def distinct(n):
	n2 = n
	ds = set()
	while n2 > 0:
		d = n2 % 10
		if d in ds:
			return False
		ds.add(d)
		n2 //= 10
	return True
y = int(stdin.readline())
y += 1
while not distinct(y):
	y += 1
print(y)


a = int(input())
for i in range(a, 100000000):
	flag = len(set(list(str(i)))) == len(list(str(i)))
	if flag == True and i > a:
		print(i)
		break


n = int(input())
for t in range(n + 1, 10000):
	i = t
	a = list()
	while i != 0:
		a.append(i % 10)
		i = i // 10
	flag = 1
	for j in range(0, len(a)):
		if a.count(a[j]) > 1:
			flag = 0
			break
	if flag == 1:
		print(t)
		break


a = int(input())
while True:
	a += 1
	b = set()
	logic = False
	for i in str(a):
		b.add(i)
	if len(b) == len(str(a)):
		break
print(a)


n = int(input())
y = n
while True:
	y = y + 1
	z = str(y)
	l = [z[i] for i in range(len(z))]
	s = set(l)
	if len(s) == 4:
		break
print(y)


year = int(input())
i = year + 1
while 1:
	l = []
	for j in str(i):
		if j not in l:
			l.append(j)
	if len(l) == len(str(i)):
		print(i)
		break
	else:
		i += 1


n = int(input())
k = n + 1
m = k % 10
l = int(k / 10) % 10
j = int(k / 10 / 10) % 10
o = int(k / 10 / 10 / 10) % 10
while m == l or m == j or m == o or (l == j) or (l == o) or (j == o):
	k = k + 1
	m = k % 10
	l = int(k / 10) % 10
	j = int(k / 10 / 10) % 10
	o = int(k / 10 / 10 / 10) % 10
print(k)


a = int(input())
i = 0
while i == 0:
	a = a + 1
	c = list(set(str(a)))
	if len(c) == 4:
		print(a)
		i = 1


x = int(input())
for i in range(1, 500):
	a = x + i
	d = a % 10
	c = a % 100 - d
	b = a % 1000 - c - d
	a = a % 10000 - c - d - b
	c = int(c / 10)
	b = int(b / 100)
	a = int(a / 1000)
	if a != b and b != c and (c != d) and (d != a) and (c != a) and (b != d):
		print(str(a) + str(b) + str(c) + str(d))
		break


n = int(input())
for i in range(n + 1, 10000):
	a = []
	d = i
	while d > 0:
		b = d % 10
		a.append(b)
		d //= 10
	count = 0
	countb = 0
	for j in range(3):
		for k in range(j + 1, 4):
			if a[j] == a[k]:
				countb = 1
				break
			elif k == 3 and a[j] != a[k]:
				count += 1
		if countb == 1:
			break
	if count == 3:
		print(i)
		break


s = 0
x = str(input())
while 1:
	a = ''.join(x)
	x = int(a)
	x = x + 1
	x = str(x)
	x = list(x)
	for i in x:
		if x.count(i) == 1:
			s += 1
	if s == len(x):
		print(''.join(x))
		break
	s = 0


y = int(input())
new = y + 1
while len(set([c for c in str(new)])) != 4:
	new += 1
print(new)


def check(n):
	r1 = n % 10
	n = n // 10
	r2 = n % 10
	n = n // 10
	r3 = n % 10
	r4 = n // 10
	if r1 != r2 and r1 != r3 and (r2 != r3) and (r1 != r4) and (r2 != r4) and (r3 != r4):
		return False
	else:
		return True
s = input()
n = int(s) + 1
a = list(s)
while check(n):
	n = n + 1
print(n)


n = input()
anno = n
while True:
	if n[0] != n[1] and n[1] != n[2] and (n[2] != n[0]) and (n[1] != n[3]) and (n[0] != n[3]) and (n[2] != n[3]) and (int(n) > int(anno)):
		break
	else:
		n = str(int(n) + 1)
anno = n
print(anno)


def f(a):
	c = list((0 for _ in range(10)))
	for i in range(4):
		x = a % 10 ** (i + 1) // 10 ** i
		if c[x] == 1:
			return False
		c[x] = 1
	return True
n = int(input()) + 1
while not f(n):
	n += 1
print(n)


s = int(input())
for i in range(1, 10000):
	a = s + i
	b = str(a)
	d = 0
	for j in range(len(b)):
		if b.count(b[j]) == 1:
			d = d + 1
		else:
			pass
	if d == len(b):
		print(a)
		break
	else:
		pass


numbers = '0123456789'

def dif(n):
	n = str(n)
	for i in range(10):
		if n.count(numbers[i]) > 1:
			return False
	return True
n = int(input()) + 1
while not dif(n):
	n += 1
print(n)


year_string = input()
year_int = int(year_string)
year_set = {*{}}
while len(year_set) != 4:
	year_int += 1
	year_string = str(year_int)
	year_set = set(year_string)
print(year_int)


n = int(input())
m = n + 1
while m > n:
	k = m
	s = []
	for i in range(4):
		d = k % 10
		s.append(d)
		k //= 10
	l = set(s)
	if len(l) < 4:
		m += 1
		continue
	else:
		print(m)
		break


n = int(input())

def is_distinct(x):
	s = str(x)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		return True
	else:
		return False
n += 1
while True:
	if is_distinct(n):
		print(n)
		break
	else:
		n += 1


rok = int(input())
hladany = rok + 1
while len(str(hladany)) != len(set(str(hladany))):
	hladany += 1
print(hladany)


def valid(num):
	s = set()
	st = str(num)
	for c in st:
		s.add(int(c))
	return len(s) == len(st)
y = int(input()) + 1
while True:
	if valid(y):
		print(y)
		break
	y += 1


def v(y):
	(y, ys, cv) = (str(y), set(), True)
	for i in y:
		ys.add(i)
	if len(y) == len(ys):
		return True
	else:
		return False
try:
	y = int(input())
	if y >= 1000 and y <= 9000:
		if v(y) == True:
			y += 1
		while v(y) != True:
			y += 1
		print(y)
except:
	pass


import sys
from random import choice, randint
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, sys.stdin.readline().strip().split())

def LI():
	return list(map(int, sys.stdin.readline().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().strip().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().strip().split()]

def LS():
	return sys.stdin.readline().strip().split()

def I():
	return int(sys.stdin.readline().strip())

def F():
	return float(sys.stdin.readline().strip())

def S():
	return sys.stdin.readline().strip()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))
inp = sys.stdin.readline
out = sys.stdout.write

def main():
	y = I()
	while True:
		y += 1
		l = set(list(str(y)))
		if len(l) == 4:
			pf(y)
			break
main()


n = int(input())
z = []
y = 0
while True:
	n = n + 1
	x = n
	y = 0
	while x != 0:
		z.append(x % 10)
		x = x // 10
	for i in range(len(z)):
		for j in range(i + 1, len(z)):
			if z[i] == z[j]:
				y = 1
				break
		if y == 1:
			break
	if y == 1:
		z.clear()
	else:
		print(n)
		break


n = int(input())
n += 1

def test(x):
	x = set(str(n))
	if len(x) != 4:
		return True
while test(n):
	n += 1
print(n)


L = input()
s = int(L)
while True:
	s += 1
	l = str(s)
	flag = False
	k = 0
	for i in range(4):
		if flag == True:
			break
		for j in range(i + 1, 4):
			if l[i] == l[j]:
				flag = True
				break
			else:
				k += 1
	if k == 6:
		print(s)
		break


y = int(input())
while 1:
	y += 1
	l = list(str(y))
	seen = set()
	flag = not any((i in seen or seen.add(i) for i in l))
	if flag:
		print(y)
		break
	else:
		pass


a = int(input()) + 1

def distinct(x):
	tab = [0] * 10
	for i in [int(z) for z in str(x)]:
		if tab[i]:
			return False
		tab[i] += 1
	return True
while not distinct(a):
	a += 1
print(a)


n = int(input())
for i in range(n + 1, 10000):
	s = str(i)
	d = list(s)
	flag = 1
	for j in s:
		if s.count(j) >= 2:
			flag = 0
	if flag == 1:
		print(i)
		break


def Numero(m):
	a = -1
	i = 0
	while a == -1 and i < len(m):
		k = i + 1
		while k < len(m) and a == -1:
			if m[i] == m[k]:
				a = 1
			k += 1
		i += 1
	return a
x = input()
a = 1
b = []
while a == 1:
	x = int(x)
	x += 1
	b = list(map(int, str(x)))
	a = Numero(b)
print(x)


import sys
local_launch = False
try:
	open('LOCAL').read()
	local_launch = True
except:
	pass
input_data = open('INPUT.txt').read() if local_launch else sys.stdin.read()
done = {'i': 0}
tokens = input_data.split()

def next_token():
	result = tokens[done['i']]
	done['i'] += 1
	return result

def next_int():
	return int(next_token())

def next_str():
	return next_token()
n = next_int()
z = n + 1

def is_pretty(n):
	count = 0
	a = n % 10
	b = n // 10 % 10
	c = n // 100 % 10
	e = n // 1000 % 10
	if a == b or a == c or a == e:
		count += 1
	if b == c or b == e:
		count += 1
	if c == e:
		count += 1
	if count > 0:
		return False
	else:
		return True
while not is_pretty(z):
	z = z + 1
print(z)


def unique(sentence):
	seen = set()
	return [x for x in sentence if not (x in seen or seen.add(x))]
str1 = input()
str2 = int(str1) + 1
while True:
	str3 = unique(str(str2))
	if len(str3) == len(str1):
		print(''.join(str3))
		break
	else:
		str2 = str2 + 1


yr = int(input())

def distinct(yr):
	ys = str(yr)
	dd = {}
	for i in range(len(ys)):
		if ys[i] not in dd:
			dd[ys[i]] = 1
		else:
			return False
	return True
final = 0
year = yr + 1
while year <= 10000:
	if distinct(year):
		final = year
		break
	year += 1
print(final)


def isDistinct(x):
	x = list(str(x))
	seen = []
	for elem in x:
		if elem not in seen:
			seen.append(elem)
		else:
			return False
	return True
x = int(input())
numDistinct = False
while not numDistinct:
	x += 1
	numDistinct = isDistinct(x)
print(x)


y = int(input())
for yi in range(y + 1, 9013):
	if len(str(yi)) == len(set(str(yi))):
		print(yi)
		break


n = int(input())
a = n
flag = 1
while flag:
	a = a + 1
	y = a % 10
	d = a // 10 % 10
	z = a // 100 % 10
	x = a // 1000
	if x == z or d == y or x == y or (x == d) or (d == z) or (y == z):
		flag = 1
	else:
		flag = 0
print(a)


def isDistinct(n):
	n = str(n)
	used = []
	for i in n:
		if i in used:
			return False
		used.append(i)
	return True
n = int(input())
n += 1
while True:
	if isDistinct(n):
		print(n)
		break
	n += 1


num = input()
nu = int(num)
while int(num) <= nu:
	nu += 1
	n = str(nu)
	if len(set(n)) == 4:
		print(n)
		break


y = int(input())
p = y + 1
plength = len(set(list(str(p))))
while plength != len(str(p)):
	p = p + 1
	plength = len(set(list(str(p))))
print(p)


s = int(input())
f = 1
for i in range(s + 1, s + 1000):
	a = i
	x = list(str(a))
	if f == 1:
		f = 0
	else:
		print(i - 1)
		break
	for j in range(0, 3):
		for k in range(j + 1, 4):
			if x[k] == x[j]:
				f = 1
				break
		if f == 1:
			break


number = input()
number = str(int(number) + 1)
while True:
	checked = True
	num = [0] * 10
	for i in number:
		if num[int(i)] == 0:
			num[int(i)] = 1
		else:
			checked = False
			break
	if checked:
		print(number)
		exit()
	else:
		number = str(int(number) + 1)


string = input()
number = int(string)
while True:
	number += 1
	string = str(number)
	if len(set(string)) == 4:
		break
print(string)


x = int(input())
while 1:
	x += 1
	a = str(x)
	if a[0] != a[1] and a[1] != a[2] and (a[2] != a[3]) and (a[0] != a[3]) and (a[1] != a[3]) and (a[0] != a[2]):
		break
	else:
		pass
print(x)


import math
n = int(input())
jud = False
while jud == False:
	ncount = [0] * 10
	n += 1
	year = str(n)
	for i in year:
		ncount[int(i)] += 1
	if max(ncount) <= 1:
		jud = True
print(year)


a = input()
c = int(a) + 1
while True:
	b = str(int(c))
	if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
		print(b)
		break
	c += 1


x = input()
x = str(int(x) + 1)

def check(n):
	count = 0
	for a in range(0, 3):
		if n[a] not in n[a + 1:]:
			count += 1
		else:
			n = str(int(n) + 1)
			return check(n)
		if a == 2 and count == 3:
			print(n)
check(x)


n = input()
k = 0
n = int(n)
n += 1
n = str(n)
while k == 0:
	p = 0
	for i in range(1, len(n)):
		for j in range(i):
			if n[i] == n[j]:
				n = int(n)
				n += 1
				n = str(n)
				p = 1
				break
	if p == 0:
		k = 1
print(n)


n = int(input())
for i in range(n + 1, 9013):
	i1 = str(i)
	flag = 0
	for j in range(len(i1)):
		k = j + 1
		while k < len(i1):
			if i1[j] == i1[k]:
				flag = 1
				break
			k = k + 1
	if flag == 0:
		print(i)
		break


def main():
	inp = input()
	yearint = int(inp)
	yearint += 1
	while True:
		flag = 0
		yearstring = str(yearint)
		for i in range(len(yearstring)):
			for j in range(i + 1, len(yearstring)):
				if yearstring[i] == yearstring[j]:
					flag = 1
		if flag == 1:
			yearint += 1
			continue
		else:
			print('{}'.format(yearint))
			break
main()


y = input()
z = int(y) + 1
y = str(z)
x = list(y)
(a, b, c, d) = (int(x[0]), int(x[1]), int(x[2]), int(x[3]))
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	z += 1
	w = list(str(z))
	(a, b, c, d) = (w[0], w[1], w[2], w[3])
print(z)


n = int(input())
while True:
	n += 1
	stringn = str(n)
	lista = list(stringn)
	used = []
	prox = False
	for i in range(len(lista)):
		if lista[i] not in used:
			used.append(lista[i])
		else:
			prox = True
			break
	if prox:
		continue
	print(n)
	break


n = int(input())
ugly = True

def beautiful(x):
	k = 1
	ugly = True
	for i in x:
		for j in range(k, 4):
			if i == x[j]:
				ugly = True
				return ugly
			else:
				ugly = False
		k = k + 1
	return ugly
while ugly:
	n = n + 1
	ugly = beautiful(str(n))
print(n)


s = int(input())
if s >= 1987 and s < 2013:
	print('2013')
else:
	while True:
		s += 1
		if len(set(str(s))) == 4:
			print(s)
			break


year = eval(input())
for minyear in range(year + 1, 9013):
	word = str(minyear)
	if len(word) == len(set(word)):
		print(word)
		break
	else:
		continue


n = int(input())
for i in range(1, 9000):
	a = n + i
	l1 = list(str(a))
	l2 = set(str(a))
	if len(l1) == len(l2):
		print(a)
		break


year = int(input())
for i in range(year + 1, year + 102):
	if len(set(str(i))) == 4:
		print(i)
		break
	else:
		continue


n = int(input())
i = n + 1
while True:
	i = str(i)
	alist = list(i)
	length = len(alist)
	t = True
	for x in alist:
		if alist.count(x) != 1:
			t = False
	if t == True:
		print(i)
		break
	else:
		i = int(i)
		i += 1


def is_beautiful_year(year):
	if len(list(year)) != len(set(year)):
		return True
	return False
data = input()
result = int(data) + 1
while is_beautiful_year(str(result)):
	result += 1
print(result)


x = input()
i = 1
p = int(x)
if 1000 <= p <= 9000:
	while i < 2:
		p += 1
		a = int(p / 1000)
		b = int(p % 1000 / 100)
		c = int(p % 100 / 10)
		d = int(p % 10)
		if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
			print(p)
			if p < p + 1:
				break


array = []
count = 0
n = int(input())
i = n + 1
while True:
	k = str(i)
	for j in range(0, 4):
		array.append(int(k[j]))
	for t in range(0, 10):
		if array.count(t) == 1:
			count += 1
	if count == 4:
		print(i)
		break
	else:
		count = 0
		array = []
	i += 1


s = input()
t = int(s)
d = 0
for i in range(t + 1, 9013):
	s1 = str(i)
	d = 0
	for j in range(0, 4):
		for k in range(j + 1, 4):
			if s1[j] != s1[k]:
				d = d + 1
			if d == 6:
				print(s1)
				exit(0)


n = int(input())
s = []
n = n + 1
i = 3
f = 0
l = n
while n != 0:
	k = n // 10 ** i
	n = n % 10 ** i
	s.append(k)
	i = i - 1
while len(set(s)) != 4:
	f = 1
	del s
	s = []
	n = l
	i = 3
	p = 4
	while p != 0:
		k = n // 10 ** i
		n = n % 10 ** i
		s.append(k)
		i = i - 1
		p = p - 1
	l = l + 1
if f == 0:
	print(l)
else:
	print(l - 1)


n = int(input()) + 1
while True:

	def ok(n):
		d = {}
		while n:
			d[n % 10] = 1
			n //= 10
		return len(d) == 4
	if ok(n):
		print(n)
		break
	n += 1


x = int(input())
longi = len(str(x))
while True:
	x += 1
	if len(set(str(x))) == longi:
		break
print(x)


y = int(input())
is_next_beautiful_year_found = False
while not is_next_beautiful_year_found:
	y = y + 1
	str_y = str(y)
	if str_y[0] not in str_y[1:] and str_y[1] not in str_y[2:] and (str_y[2] not in str_y[3:]):
		is_next_beautiful_year_found = True
		break
print(y)


import sys
if False:
	input = open('beautifulyear.txt', 'r')
else:
	input = sys.stdin
counting = int(input.readline())
found = False
while found != True:
	counting = counting + 1
	year = str(counting)
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]) and (year[1] != year[2]) and (year[1] != year[3]) and (year[2] != year[3]):
		print(year)
		found = True


n = int(input())
for i in range(n + 1, 9013):
	i = str(i)
	h = len(set(i))
	if h == 4:
		print(i)
		break


def print_date(date):
	while True:
		date += 1
		if len(set(str(date))) == 4:
			print(date)
			break
print_date(int(input()))


y = int(input())
y = y + 1
while 1:
	l1 = []
	for i in str(y):
		if i not in l1:
			l1.append(i)
	if ''.join(l1) == str(y):
		break
	y = y + 1
print(y)


s = int(input())

def main(s):
	while True:
		s += 1
		st = str(s)
		if len(set(st)) == len(st):
			return s
	return -1
print(main(s))


def main():
	inp = int(input())
	for i in range(inp + 1, 9100):
		s = str(i)
		if s[0] == s[1] or s[0] == s[2] or s[0] == s[3] or (s[1] == s[2]) or (s[1] == s[3]) or (s[2] == s[3]):
			continue
		else:
			print(s)
			break
main()


a = input()
while 1:
	a = str(int(a) + 1)
	b = a.count(a[0])
	c = a.count(a[1])
	d = a.count(a[2])
	if b == 1 and c == 1 and (d == 1):
		print(a)
		break


n = input()
year = int(n)
year += 1
n = list(str(year))
while not n.count(n[0]) == n.count(n[1]) == n.count(n[2]) == n.count(n[3]) == 1:
	year += 1
	n = list(str(year))
print(year)


y = int(input())
yr = list(str(y))
for i in range(0, 4):
	yr[i] = int(yr[i])
p = 0
while p == 0:
	p = 1
	y = y + 1
	yr = list(str(y))
	m = []
	for i in range(0, 4):
		if yr[i] in m:
			p = 0
			break
		m.append(yr[i])
print(y)


a = int(input())
while 1:
	a += 1
	n = str(a)
	l = []
	for i in n:
		if i not in l:
			l.append(i)
	if len(l) == 4:
		break
print(a)


s = input()
while int(s) > 999:
	s = int(s) + 1
	if len(set(str(s))) == 4:
		print(s)
		break


dis_von = 0
set = []
data = int(input())
while dis_von == 0:
	data += 1
	data = str(data)
	for u in range(4):
		if u == 0:
			set.append(data[u])
		elif data[u] not in set:
			set.append(data[u])
		if len(set) == 4:
			dis_von = 1
	set = []
	data = int(data)
print(data)


3
y = int(input())
ans = y + 1
while True:
	if len(set(list(str(ans)))) == 4:
		break
	ans += 1
print(ans)


N = int(input())
while True:
	N += 1
	s = str(N)
	i = 0
	find = True
	while i < len(s):
		j = 0
		while j < len(s):
			if i != j and s[i] == s[j]:
				find = False
				break
			j += 1
		if not find:
			break
		i += 1
	if find:
		print(s)
		break


n = int(input())
ans = n
boo = True
while boo:
	ans = ans + 1
	s = str(ans)
	se = set(s)
	if len(se) == len(s):
		boo = False
print(ans)


n = int(input())
f = 0
n += 1
while f != 1:
	a = [int(x) for x in str(n)]
	if len(set(a)) == 4:
		f = 1
		break
	n += 1
print(int(''.join(map(str, a))))


(year, x) = (int(input()) + 1, 0)
while x != 1:
	if len(''.join(set(str(year)))) == 4:
		print(year)
		x = x + 1
	else:
		year = year + 1


def razl(x):
	a = x % 10
	b = x // 10 % 10
	c = x // 100 % 10
	d = x // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return True
	else:
		return False
n = int(input())
n += 1
while True:
	if razl(n):
		print(n)
		exit()
	n += 1


n = int(input())
flag = True
while flag == True:
	n = n + 1
	check = list(str(n))
	check = list(set(check))
	if len(check) == 4:
		flag = False
print(n)


x = int(input())
i = 1000
j = 0
lst = []
for j in range(9000):
	y = str(i)
	y1 = int(y[0])
	y2 = int(y[1])
	y3 = int(y[2])
	y4 = int(y[3])
	if y1 != y2 and y1 != y3 and (y1 != y4) and (y2 != y3) and (y2 != y4) and (y3 != y4):
		lst.append(int(i))
	i += 1
for j in range(len(lst) - 1):
	if x < lst[j]:
		print(lst[j])
		j += 9000
		break
	j += 1


x = int(input())
a = x + 1
for i in range(a, 9999, 1):
	d1 = int(i / 10)
	d2 = int(d1 / 10)
	d3 = int(d2 / 10)
	r1 = i % 10
	r2 = d1 % 10
	r3 = d2 % 10
	r4 = d3 % 10
	if r1 == r2 or r1 == r3 or r1 == r4 or (r2 == r3) or (r3 == r4) or (r2 == r4):
		pass
	else:
		print(i)
		break


def get_next_year(yr):
	nxt_yr = int(yr)
	c = 0
	while c < len(yr):
		nxt_yr = nxt_yr + 1
		nxt_yr_dgts = set()
		for i in str(nxt_yr):
			nxt_yr_dgts.add(i)
		c = len(nxt_yr_dgts)
	return nxt_yr
print(get_next_year(input().strip(' ')))


x = int(input())
for i in range(x + 1, 100000000):
	i = str(i)
	if i[0] != i[1] and i[0] != i[2] and (i[0] != i[3]) and (i[1] != i[2]) and (i[1] != i[3]) and (i[2] != i[3]):
		print(i)
		break


n = int(input())
for i in range(n + 1, 9100):
	(a, b, c, d) = (str(i)[0], str(i)[1], str(i)[2], str(i)[3])
	if len(set([a, b, c, d])) == 4:
		print(i)
		break


start = int(input())
for i in range(8000):
	year = start + i + 1
	x = str(year)
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		print(x)
		break


n = int(input()) + 1
while len(set([n // 1000, n // 100 % 10, n // 10 % 10, n % 10])) != 4:
	n += 1
print(n)


take1 = input()
take1 = int(take1)
take2 = int(take1)
for i in range(101):
	take2 = take2 + 1
	a = int(take2 / 1000)
	b = int(take2 / 100 % 10)
	c = int(take2 / 10 % 10)
	d = int(take2 % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(take2)
		break


a = int(input())
i = a + 1
c = True
while c:
	if len(set(str(i))) == 4:
		print(i)
		c = False
	i += 1


y = input()
year = str(int(y) + 1)
running = True
count = 0
while running:
	for i in year:
		for j in year:
			if i == j:
				count += 1
	count -= 4
	if count == 0:
		print(year)
		running = False
	else:
		count = 0
		year = str(int(year) + 1)


y = int(input()) + 1
i = 0
while i < 3:
	if str(y).count(str(y)[i]) > 1:
		y += 1
		i = 0
	else:
		i += 1
print(y)


n = int(input())
result = 0
while n < 10000:
	n += 1
	n1 = list(str(n))
	if len(set(n1)) == 4:
		result = n
		break
print(result)


y = int(input())
while True:
	y += 1
	digits = list(str(y))
	wodups = set(digits)
	if len(digits) == len(wodups):
		print(y)
		break


n = int(input())
k = n + 1
while True:
	l = set(str(k))
	if len(l) == 4:
		print(k)
		break
	else:
		k = k + 1


def unique(n):
	s = str(n)
	checked = set()
	for letter in s:
		if letter in checked:
			return False
		checked.add(letter)
	return True

def check2(y):
	for i in range(y + 1, 100000):
		if unique(i):
			return i
y = int(input())
print(check2(y))


from heapq import *

def int_raw():
	return int(input())

def ss_raw():
	return input().split()

def ints_raw():
	return list(map(int, input().split()))
y = int_raw()

def main():
	x = y + 1
	while True:
		if len(set(str(x))) == len(str(x)):
			return x
		x += 1
print(main())


def isd(a):
	for i in range(len(str(a))):
		for j in range(i + 1, len(str(a))):
			if str(a)[i] == str(a)[j]:
				return False
	return True
a = int(input()) + 1
k = False
while k == False:
	k = isd(a)
	if k == False:
		a += 1
print(a)


year = input()
year = str(int(year) + 1)
while True:
	year_digits = set()
	for digit in year:
		year_digits.add(digit)
	if len(year_digits) == len(year):
		print(year)
		break
	else:
		year = str(int(year) + 1)


n = int(input())
x = n + 1
con = True
while con:
	if str(x)[0] == str(x)[1] or str(x)[1] == str(x)[2] or str(x)[2] == str(x)[3] or (str(x)[1] == str(x)[3]) or (str(x)[0] == str(x)[3]) or (str(x)[0] == str(x)[2]):
		x += 1
	else:
		print(x)
		con = False


answer = str(input())
answer = str(int(answer) + 1)
while answer.count(answer[0]) > 1 or answer.count(answer[1]) > 1 or answer.count(answer[2]) > 1 or (answer.count(answer[3]) > 1):
	answer = str(int(answer) + 1)
print(answer)


n = int(input())
while n > 0:
	n += 1
	ar = n
	a = list()
	flag = 0
	while ar > 0:
		rem = ar % 10
		if rem in a:
			flag = 1
			break
		else:
			a.append(rem)
		ar //= 10
	if flag != 1:
		print(n)
		break


i = input()
while True:
	i = str(int(i) + 1)
	for l in i:
		if i.count(l) > 1:
			break
	else:
		break
print(i)


year = int(input())
status = 0
while status != 1:
	year += 1
	number = str(year)
	d = {}
	for i in range(0, len(number)):
		if number[i] in d:
			d[number[i]] += 1
		else:
			d[number[i]] = 1
	count = 0
	for key in d:
		if d[key] == 1:
			count += 1
	if count == len(number):
		status = 1
print(year)


y = input()

def allUnique(t):
	for i in range(4):
		for j in range(i + 1, 4):
			if t[i] == t[j]:
				return 0
	return 1
while 1:
	y = str(int(y) + 1)
	if allUnique(y):
		print(y)
		break
	else:
		continue


import time

def checkIfDuplicates(listOfElems):
	if len(listOfElems) == len(set(listOfElems)):
		return False
	else:
		return True
year = int(input(''))
j = 0
my_list = []
for i in str(year):
	my_list.append(i)
while True:
	year += 1
	for x in str(year):
		my_list[j] = str(x)
		j += 1
	j = 0
	if not checkIfDuplicates(my_list):
		print(my_list[0] + my_list[1] + my_list[2] + my_list[3])
		break


__author__ = 'User'
import sys
year = int(sys.stdin.readline())
f = False
while not f:
	year = year + 1
	sYear = str(year)
	s = 0
	l = len(sYear)
	for i in range(0, l):
		s = s + sYear.count(sYear[i])
	if s == l:
		f = True
		print(sYear)


y = input()
y = str(int(y) + 1)
hasil = False
while hasil == False:
	y = str(y)
	array = []
	for i in range(len(y)):
		if y[i] not in array:
			hasil = True
			array += [y[i]]
		elif y[i] in array:
			hasil = False
			break
	y = int(y)
	y += 1
print(int(y) - 1)


y = input()
for i in range(int(y) + 1, 9999):
	n = list(str(i))
	(a, b, c, d) = n
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		break


def check(x):
	x1 = x % 10
	x //= 10
	x2 = x % 10
	x //= 10
	x3 = x % 10
	x //= 10
	if x != x1 and x != x2 and (x != x3) and (x1 != x2) and (x1 != x3) and (x2 != x3):
		return True
	return False

def year(n):
	n += 1
	while not check(n):
		n += 1
	return n
print(year(int(input())))


def check(n):
	t = n
	a = []
	while t > 0:
		r = t % 10
		if r not in a:
			a.append(r)
		else:
			return False
		t //= 10
	if len(a) == 4:
		return True
	else:
		return False
t = int(input())
for i in range(t + 1, 10000):
	if check(i):
		print(i)
		break


n = int(input())
for i in range(n + 1, 90000):
	s = list(str(i))
	temp = 0
	for j in s:
		if s.count(j) == 1:
			temp += 1
			continue
		else:
			break
	if temp == len(str(i)):
		print(i)
		break


x = input()

def distinct(year):
	for i in range(len(year) - 1):
		for j in range(i + 1, len(year)):
			if int(year[i]) == int(year[j]):
				return 0
	return 1
x = int(x) + 1
while distinct(str(x)) != 1:
	x = int(x) + 1
print(int(x))


for year in range(int(input()) + 1, 9013):
	modified_year = set(list(str(year)))
	if len(modified_year) == 4:
		print(year)
		break


year = int(input())
new_year = year + 1
while len(set(str(new_year))) != len(str(new_year)):
	new_year += 1
print(new_year)


y = int(input()) + 1
q = True
while q:
	if len(list(set(str(y)))) == 4:
		q = False
		print(y)
	else:
		y += 1


n = int(input())
k = 0
while k < 1000:
	if len(str(n + 1)) == len(set(str(n + 1))):
		print(n + 1)
		k = 1001
	else:
		k += 1
		n += 1


x = input()
x = int(x) + 1
y = [int(i) for i in str(x)]
z = set(y)
while len(y) != len(z):
	x = x + 1
	y = [int(i) for i in str(x)]
	z = set(y)
print(x)


x = input()
ctr = 0
while ctr == 0:
	x = int(x) + 1
	y = []
	x = str(x)
	y = list(x)
	z = set(y)
	if len(y) != len(z):
		ctr = 0
	else:
		break
print(x)


from itertools import permutations
n = int(input())
a = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
x = list(permutations(a, 4))
for i in range(len(x)):
	p = ''.join(x[i])
	x[i] = int(p)
x.sort()
for i in range(len(x)):
	if x[i] > n:
		print(x[i])
		exit()


n = int(input())
i = n + 1
while True:
	s = str(i)
	a = [0] * 10
	land = False
	for j in s:
		a[int(j)] += 1
		if a[int(j)] > 1:
			land = True
			break
	if land == True:
		i += 1
		continue
	else:
		break
print(i)


def daf(a):
	a = int(a) + 1
	for g in range(101):
		b = []
		for i in str(a):
			b.append(i)
		v = set(b)
		if len(v) == len(b):
			return a
		else:
			a += 1
print(daf(input()))


n = input()
b = []
for i in range(1, 1000):
	s = int(n) + i
	l = list(str(s))
	a = set(l)
	if len(l) == len(a):
		b.append(s)
print(b[0])


n = int(input())

def f(x):
	x = str(x)
	for i in x:
		if x.count(i) > 1:
			return 0
	return 1
while True:
	n += 1
	if f(n):
		print(n)
		break


n = int(input())
n = n + 1
s = str(n)
p = set(s)
flag = 1
while flag:
	if len(p) == 4:
		flag = 0
	else:
		n = n + 1
		s = str(n)
		p = set(s)
print(n)


y = int(input())
f = 0
y = y + 1
while f == 0:
	n = y
	a = n % 10
	n = n // 10
	b = n % 10
	n = n // 10
	c = n % 10
	n = n // 10
	d = n % 10
	if a != b and a != c and (a != d) and (b != d) and (c != d) and (b != c):
		print(y)
		break
	y = y + 1


def isDif(x):
	done = []
	while x > 0:
		if x % 10 in done:
			return False
		done.append(x % 10)
		x //= 10
	return True
year = int(input())
ans = year + 1
while not isDif(ans):
	ans += 1
print(ans)


import math
a = input()
a = int(a)
a = a + 1
while True:
	b = a / 1000
	b = math.floor(b)
	c = a % 1000 / 100
	c = math.floor(c)
	d = a % 1000 % 100 / 10
	d = math.floor(d)
	e = a % 1000 % 100 % 10
	e = math.floor(e)
	a = b * 1000 + c * 100 + d * 10 + e
	if b == c or b == d or b == e or (c == d) or (c == e) or (d == e):
		a = a + 1
		continue
	else:
		a = int(a)
		print(a)
		break


def main(year):
	year = str(int(year) + 1)
	while year[0] == year[1] or year[0] == year[2] or year[0] == year[3] or (year[1] == year[2]) or (year[1] == year[3]) or (year[2] == year[3]):
		year = str(int(year) + 1)
	return year
year = input()
print(main(year))


x = int(input())
for i in range(x + 1, 10000):
	a = set()
	s = str(i)
	for j in s:
		a.add(int(j))
	if len(a) == 4:
		print(i)
		break


s = int(input())
for i in range(s + 1, 10000):
	t = str(i)
	if t[0] != t[1] and t[0] != t[2] and (t[0] != t[3]) and (t[1] != t[2]) and (t[1] != t[3]) and (t[2] != t[3]):
		print(i)
		break


n = int(input())
t = n + 1
a = []
ok = True
while ok:
	a.append(t // 1000)
	if t // 100 % 10 != t // 1000:
		a.append(t // 100 % 10)
	if t // 10 % 10 != t // 100 % 10 and t // 10 % 10 != t // 1000:
		a.append(t // 10 % 10)
	if t % 10 != t // 10 % 10 and t % 10 != t // 100 % 10 and (t % 10 != t // 1000):
		a.append(t % 10)
	if len(a) == 4:
		ok = False
		print(t)
	else:
		a.clear()
		t += 1


def isdistinct(numberstr):
	i = 0
	k = 0
	while i < 10:
		if str(i) in numberstr:
			k = k + 1
		i = i + 1
	if k == 4:
		return True
	else:
		return False
year = int(input())
j = 0
while j < 10000:
	year = year + 1
	if isdistinct(str(year)) == True:
		print(str(year))
		break
	j = j + 1


rok = int(input())
while True:
	rok += 1
	spravnych = 0
	for i in range(4):
		if str(rok)[i] not in str(rok)[:i]:
			spravnych += 1
	if spravnych == 4:
		print(rok)
		break


x = int(input())
isdone = False
y = x + 1
while isdone == False:
	lst = []
	isbreak = False
	for item in str(y):
		if len(lst) == 0:
			lst.append(item)
		elif item in lst:
			isbreak = True
			break
		else:
			lst.append(item)
	if isbreak == False:
		isdone = True
	y += 1
print(y - 1)


s1 = input()
s2 = int(s1)
while 1:
	s2 += 1
	s3 = str(s2)
	if s3.count(s3[0]) == s3.count(s3[1]) == s3.count(s3[2]) == s3.count(s3[3]) == 1:
		print(s2)
		break


a = input()
b = int(a)
for i in range(b + 1, 9999):
	c = str(i)
	if c[0] != c[1] and c[0] != c[2] and (c[0] != c[3]) and (c[1] != c[2]) and (c[2] != c[3]) and (c[1] != c[3]):
		print(i)
		break


s = int(input())
for i in range(s, 9013):
	p = i + 1
	ls = list(set(str(p)))
	if len(ls) == 4:
		print(p)
		break


n = int(input())
number = 0
for i in range(n + 1, 20000):
	a = i // 1000
	b = i % 1000 // 100
	c = i % 100 // 10
	d = i % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		number = i
		break
print(number)


def f(a):
	l = list(a)
	m = set(l)
	if len(l) == len(m):
		return True
	return False
a = int(input())
i = a + 1
while True:
	if f(str(i)):
		print(i)
		break
	else:
		i = int(i) + 1


n = int(input())
s = 1
k = s + n
j = 0
j = j + k
for j in range(n + 1, 9999):
	l = str(j)
	if (l[0] != l[1] and l[0] != l[2] and (l[0] != l[3])) and (l[1] != l[0] and l[1] != l[2] and (l[1] != l[3])) and (l[2] != l[0] and l[2] != l[1] and (l[2] != l[3])) and (l[3] != l[0] and l[3] != l[2] and (l[3] != l[1])):
		print(j)
		break


def distinct(i):
	d = [0] * 10
	while i > 0:
		d[int(i % 10)] += 1
		i = int(i / 10)
	for i in range(10):
		if d[i] > 1:
			return False
	return True
y = int(input())
for i in range(y + 1, 9013):
	if distinct(i):
		print(i)
		break


year = int(input())
while True:
	dict = {}
	year += 1
	for i in str(year):
		if i not in dict:
			dict[i] = 1
		else:
			dict[i] += 1
	if len(dict) == 4:
		print(year)
		break


y = input()
while True:
	y = str(int(y) + 1)
	if len(set([y[0], y[1], y[2], y[3]])) == 4:
		print(y)
		break


n = int(input())
n += 1
while True:
	num = n
	l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while num > 0:
		k = num % 10
		if l[k] == 0:
			l[k] = 1
		else:
			break
		num //= 10
	if l.count(1) == 4:
		print(n)
		break
	else:
		n += 1


year = int(input())
year1 = str(year + 1)
while year1[0] == year1[1] or year1[0] == year1[2] or year1[0] == year1[3] or (year1[1] == year1[2]) or (year1[1] == year1[3]) or (year1[2] == year1[3]):
	year1 = str(int(year1) + 1)
print(year1)


s = input()
y = int(s)

def check(s):
	if s[0] != s[1] != s[2] != s[0] != s[3] != s[2] != s[3] != s[1]:
		return True
	else:
		return False
while True:
	if check(str(y + 1)):
		print(y + 1)
		break
	else:
		y += 1


def beautifulYear(year):
	if int(year) >= 1000 and int(year) <= 9000:
		while True:
			year = str(int(year) + 1)
			if len(set(year)) == 4:
				return year
yr = input()
print(beautifulYear(yr))


n = input()
p = int(n)
for i in range(p + 1, 9013):
	s = str(i)
	a = s[0]
	b = s[1]
	c = s[2]
	d = s[3]
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(s)
		break


z = int(input())
while True:
	z += 1
	(c, v, b, n) = [int(a) for a in str(z)]
	if c != v and c != b and (c != n) and (b != v) and (n != v) and (b != n):
		break
print(z)


import sys
import math
stra = int(input())
stra += 1
com = str(stra)
(a, b, c, d) = (com[0], com[1], com[2], com[3])
while not (a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d)):
	stra += 1
	com = str(stra)
	(a, b, c, d) = (com[0], com[1], com[2], com[3])
print(stra)


a = int(input())
for i in range(a, 9999):
	if len(str(i + 1)) == len(set(str(i + 1))):
		print(i + 1)
		break


import re

def checkYear(fnumber):
	zero = len(re.findall('0', fnumber))
	one = len(re.findall('1', fnumber))
	two = len(re.findall('2', fnumber))
	three = len(re.findall('3', fnumber))
	four = len(re.findall('4', fnumber))
	five = len(re.findall('5', fnumber))
	six = len(re.findall('6', fnumber))
	seven = len(re.findall('7', fnumber))
	eight = len(re.findall('8', fnumber))
	nine = len(re.findall('9', fnumber))
	if zero > 1 or one > 1 or two > 1 or (one > 1) or (two > 1) or (three > 1) or (four > 1) or (five > 1) or (six > 1) or (seven > 1) or (eight > 1) or (nine > 1):
		return False
	else:
		return True
year = int(input())
found = False
i = year + 1
while not found:
	if checkYear(str(i)):
		found = True
		answer = i
	else:
		i += 1
print(answer)


def calc(y):
	while True:
		t = y
		s = []
		while t > 0:
			s.append(t % 10)
			t //= 10
		if len(s) == len(set(s)):
			return y
		y += 1
y = int(input())
print(calc(y + 1))


def func(i):
	st = str(i)
	if st[0] == st[1] or st[0] == st[2] or st[0] == st[3] or (st[1] == st[2]) or (st[1] == st[3]) or (st[2] == st[3]):
		return False
	return True
s = input()
s1 = int(s)
for i in range(s1 + 1, 9999, 1):
	if func(i) == True:
		print(i)
		break


y = input()
x = int(y)
l = len(y)
l1 = 0
while 1:
	x += 1
	se = set(str(x))
	l1 = len(se)
	if l1 == l:
		break
	else:
		continue
print(x)


def func():
	n = int(input())
	for i in range(n + 1, 9013):
		x = i
		i = str(i)
		i = list(i)
		i = list(set(i))
		if len(i) == 4:
			print(x)
			return
func()


yr = int(input())
yr += 1
while True:
	yrs = str(yr)
	c = 0
	yrsdu = []
	for ji in yrs:
		if ji not in yrsdu:
			c = c + 1
			yrsdu.append(ji)
	if c == len(yrs):
		print(yr)
		break
	else:
		yr += 1


god = int(input()) + 1
while len(set(str(god))) != 4:
	god += 1
print(god)


y = int(input())

def diff(a):
	a.sort()
	res = False
	for i in range(1, len(a)):
		if a[i] <= a[i - 1]:
			res = True
			break
	return res
z = y
flag = True
while flag:
	z = z + 1
	flag = diff([z % 10, z // 10 % 10, z // 100 % 10, z // 1000 % 10])
print(z)


def is_distinct(number):
	digits = [int(d) for d in str(number)]
	if digits[0] != digits[1] and digits[0] != digits[2] and (digits[0] != digits[3]) and (digits[1] != digits[2]) and (digits[1] != digits[3]) and (digits[2] != digits[3]):
		return True
year = int(input())
i = year + 1
while True:
	if is_distinct(i):
		print(i)
		break
	i += 1


s = input()
l = int(s)
l = l + 1
s = str(l)
mul = 1
x = 2
while x != 1:
	mul = 1
	for i in range(len(s)):
		c = s.count(s[i])
		mul = mul * c
	if mul == 1:
		x = 1
	l = l + 1
	s = str(l)
print(l - 1)


def is_distinct(year):
	years = str(year)
	s = set()
	for c in years:
		if c in s:
			return False
		else:
			s.add(c)
	return True

def upper_distinct(year):
	year += 1
	while True:
		if is_distinct(year):
			return year
		else:
			year += 1

def main():
	first_line = input()
	first_line = first_line.split()
	year = int(first_line[0])
	print(upper_distinct(year))
main()


def solve():
	y = int(input()) + 1
	while True:
		if len(set(str(y))) == len(str(y)):
			print(y)
			break
		y += 1
solve()


year = int(input()) + 1
st = set(str(year))
while True:
	if len(st) == 4:
		print(year)
		break
	else:
		year += 1
		st = set(str(year))


n = int(input())
different = False
while not different:
	n += 1
	if len(set(str(n))) == len(str(n)):
		different = True
print(n)


num = int(input())
i = 1
y = 0
while i + num < 10000:
	if len(set(str(num + i))) == 4:
		y = num + i
		break
	i += 1
print(y)


import collections
n = int(input())
p = 1
while p:
	n += 1
	l = collections.Counter(str(n))
	if len(l) == 4:
		p = 0
		break
print(n)


from collections import Counter

def check(a):
	for i in range(a + 1, 9013):
		if len(Counter(str(i))) == 4:
			return i
y = int(input())
print(check(y))


t = int(input())
while True:
	t = t + 1
	p = str(t)
	m = list(dict.fromkeys(p))
	if len(m) == len(p):
		print(t)
		break


n = int(input())
while True:
	n += 1
	flag = True
	for i in range(10):
		if str(n).count(str(i)) > 1:
			flag = False
			break
	if flag == True:
		print(n)
		break


a = int(input()) + 1
x = list(str(a))
while len(set(x)) != len(x):
	a += 1
	x = list(str(a))
	x = [int(x[i]) for i in range(len(x))]
print(a)


a = int(input())
count = 0
while count == 0:
	a = a + 1
	c = set(str(a))
	if len(c) == 4:
		count = 1
print(a)


a = int(input())
ans = ''
a += 1
while 1:
	l = []
	for i in str(a):
		l.append(i)
	if l[0] != l[1] and l[0] != l[2] and (l[0] != l[3]) and (l[1] != l[2]) and (l[1] != l[3]) and (l[2] != l[3]):
		for i in l:
			ans += i
		break
	else:
		a += 1
print(int(ans))


y = int(input())
while 1:
	y = y + 1
	ys = str(y)
	if ys[0] == ys[1] or ys[0] == ys[2] or ys[0] == ys[3] or (ys[1] == ys[2]) or (ys[1] == ys[3]) or (ys[2] == ys[3]):
		continue
	else:
		print(y)
		break


n = int(input())
while True:
	n = n + 1
	s = list(str(n))
	if len(s) == len(set(s)):
		print(n)
		exit()


year = str(int(input()) + 1)
mar = True
while mar:
	if year[0] != year[1] and year[0] != year[2] and (year[0] != year[3]) and (year[1] != year[0]) and (year[1] != year[2]) and (year[1] != year[3]) and (year[2] != year[1]) and (year[2] != year[0]) and (year[0] != year[3]) and (year[3] != year[1]) and (year[3] != year[2]) and (year[3] != year[0]):
		print(year)
		mar = False
	else:
		year = str(int(year) + 1)


n = int(input()) + 1
c = True
while c:
	if len(str(n)) == len(set(str(n))):
		c = False
		break
	n += 1
print(n)


x = int(input())
y = ''
x += 1
while True:
	for i in str(x):
		if i not in y:
			y += i
		else:
			pass
	if len(y) >= 4:
		break
	else:
		y = ''
	x += 1
print(y)


n = int(input())
for i in range(n + 1, 10000):
	temp = i
	j = 0
	ls = []
	while temp > 0:
		rem = temp % 10
		ls.append(rem)
		temp = temp // 10
	flag = 0
	for k in range(4):
		for l in range(k + 1, 4):
			if ls[k] == ls[l]:
				flag = 1
				break
	if flag == 0:
		print(i)
		break


year = int(input())
if year == 9000:
	print(9012)
else:
	for i in range(year + 1, 9013):
		if len(set(str(i))) == 4:
			print(i)
			break


n = int(input())
a = True
while a:
	n += 1
	k = str(n)
	L = len(set(k))
	if len(k) == L:
		print(k)
		a = not a


year = int(input()) + 1
y = str(year)
length = len(list(y))
while len(set(y)) != length:
	year += 1
	y = str(year)
	length = len(list(y))
print(year)


num = int(input())
check = True
l = num + 1
while check:
	lis1 = []
	lis = list(str(l))
	for value in lis:
		if value not in lis1:
			lis1.append(value)
	if len(lis1) == len(lis):
		check = False
	else:
		l += 1
print(l)


def main():
	y = int(input()) + 1
	while True:
		if len(set((c for c in str(y)))) == 4:
			return y
		y += 1
print(main())


def beautiful_year(year):
	year = str(year)
	sz = len(year)
	for i in range(sz):
		if year[i] in year[i + 1:sz]:
			return True
	return False

def main():
	year = int(input())
	stop = True
	ans = 0
	while stop:
		year = year + 1
		stop = beautiful_year(year)
	print(year)
main()


m = int(input())
while True:
	m += 1
	x = str(m)
	for i in range(len(x)):
		if x[i] in x[i + 1:]:
			break
	else:
		break
print(m)


b = int(input())

def div(x):
	vis = [False for i in range(15)]
	while x:
		if vis[x % 10] == True:
			return False
		vis[x % 10] = True
		x //= 10
	return True
for i in range(b + 1, 15000, 1):
	if div(i):
		print(i)
		break


n = int(input())
i = n + 1
while True:
	st = str(i)
	s = []
	for w in st:
		if w not in s:
			s.append(w)
	if len(s) == 4:
		break
	i += 1
print(i)


t = input()
year = ''
for i in range(int(t), int(t) + 200):
	if len(set(str(i))) == 4 and i > int(t):
		year += str(i)
print(year[0:4])


n = input()
m = str(int(n) + 1)
s = set(m)
while len(s) != 4:
	m = str(int(m) + 1)
	s = set(m)
print(m)


y = int(input())
y += 1
while True:
	tab = []
	for num in str(y):
		if num not in tab:
			tab.append(num)
	if len(tab) == len(str(y)):
		print(str(y))
		break
	y += 1


def distinctYear(yearly):
	nums = list(str(yearly))
	if nums[0] != nums[1] and nums[0] != nums[2] and (nums[0] != nums[3]):
		if nums[1] != nums[2] and nums[1] != nums[3]:
			if nums[2] != nums[3]:
				return False
	return True
year = int(input())
year += 1
while distinctYear(year):
	year += 1
print(year)


y = int(input())
y += 1
flag = False
while not flag:
	ystr = str(y)
	if len(set(ystr)) == len(ystr):
		flag = True
	else:
		y += 1
print(y)


from collections import OrderedDict
t = input()
m = ''
c = 0
flag = 0
x = int(t) + 1
while x >= int(t) and x < 9876:
	x = str(x)
	m = ''.join(OrderedDict.fromkeys(x).keys())
	c = len(m)
	if c == 4:
		flag = 1
		break
	n = int(x)
	n += 1
	x = n
if flag == 1:
	x = int(m)
	print(x)


p = input()
while 1:
	p = int(p) + 1
	p = str(p)
	a = int(p[0])
	b = int(p[1])
	c = int(p[2])
	d = int(p[3])
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(p)
		break


from sys import stdin
input = stdin.readline

def year(n):
	while len(str(n)) != len(set(str(n))):
		n += 1
	return n
print(year(int(input()) + 1))


n = int(input())
while True:
	n = int(n)
	n = n + 1
	n = str(n)
	n_dec = {*n}
	if len(n) == len(n_dec):
		print(n)
		break


def fun(s):
	a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for c in s:
		a[int(c) - 1] += 1
	cnt = 0
	for j in a:
		if j == 1:
			cnt += 1
	if cnt == 4:
		return True
	else:
		return False
y = input()
y = str(int(y) + 1)
while not fun(y):
	y = str(int(y) + 1)
print(y)


def calcuniqdig(n):
	s = str(n)
	for i in s:
		if s.count(i) > 1:
			return False
	return True
n = int(input())
while True:
	n += 1
	if calcuniqdig(n):
		print(n)
		break


a = int(input()) + 1
a1 = a // 1000
a2 = a // 100 % 10
a3 = a // 10 % 10
a4 = a % 10
while not (a1 != a2 and a1 != a3 and (a1 != a4) and (a2 != a3) and (a2 != a4) and (a3 != a4)):
	a += 1
	a1 = a // 1000
	a2 = a // 100 % 10
	a3 = a // 10 % 10
	a4 = a % 10
print(str(a1) + str(a2) + str(a3) + str(a4), sep='')


n = int(input())
for y in range(n + 1, 10000):
	(d1, d2, d3, d4) = (y // 1000, y // 100 % 10, y // 10 % 10, y % 10)
	if d1 != d2 and d1 != d3 and (d1 != d4) and (d2 != d3) and (d2 != d4) and (d3 != d4):
		print(y)
		break


year = int(input())
for num in range(year + 1, 10000):
	for item in str(num):
		if str(num).count(item) > 1:
			break
	else:
		print(num)
		break


a = int(input())
a += 1
lengh_of_different_numbers = len(set(str(a)))
while lengh_of_different_numbers != 4:
	a += 1
	lengh_of_different_numbers = len(set(str(a)))
print(a)


year = int(input())
bandera = False
cadena = ''
while bandera == False:
	year = year + 1
	cadena = str(year)
	if cadena[0] != cadena[1] and cadena[0] != cadena[2] and (cadena[0] != cadena[3]) and (cadena[1] != cadena[2]) and (cadena[1] != cadena[3]) and (cadena[2] != cadena[3]):
		bandera = True
print(year)


n = int(input())
for i in range(n + 1, 9020):
	k = ''
	for j in str(i):
		if j not in k:
			k += j
	if len(k) == 4:
		break
print(i)


def beautify_year(x):
	s = 1
	for i in range(len(x)):
		if x.count(x[i]) != 1:
			s = 0
			break
	return s
a = int(input())
for i in range(9000):
	a += 1
	if beautify_year(str(a)) == 1:
		print(a)
		break


god = int(input())

def beatiful_year(god):
	god = god + 1
	while len(set(str(god))) < 4:
		god = god + 1
	return god
print(beatiful_year(god))


y = int(input())
while True:
	y += 1
	n = y
	a = n % 10
	n = n // 10
	b = n % 10
	n = n // 10
	c = n % 10
	n = n // 10
	if a != b and b != c and (c != n) and (a != n) and (a != c) and (b != n):
		break
print(y)


x = input()
new_num = int(x) + 1
new_str = str(new_num)
y = 0
for i in range(2):
	for i in range(4):
		y = new_str.count(new_str[i])
		if y >= 2:
			while y >= 2:
				new_num += 1
				new_str = str(new_num)
				y = new_str.count(new_str[i])
print(new_num)


inyear = int(input())
n = []
for t in range(1, 10):
	for h in range(10):
		for d in range(10):
			for u in range(10):
				if t != h and t != d and (t != u):
					if h != d and h != u:
						if d != u:
							n.append(int(str(t) + str(h) + str(d) + str(u)))
for year in n:
	if year > inyear:
		print(year)
		break


s = input()
n = int(s)
s = str(n + 1)
a = set(map(int, s))
while len(a) < 4:
	n += 1
	s = str(n)
	a = set(map(int, s))
print(s)


def is_cute(num):
	if len(set(str(num))) == len(str(num)):
		return True
	return False
n = int(input()) + 1
while not is_cute(n):
	n += 1
print(n)


def check(l):
	li = list(str(l))
	s = set(li)
	if len(s) == 4:
		return True
	else:
		return False
y1 = int(input())
y2 = 9012
for i in range(y1 + 1, y2 + 1):
	if check(i):
		print(i)
		break


n = int(input())
while True:
	n += 1
	m = n
	m = str(m)
	l = list(m)
	s = set(l)
	if len(l) == len(s):
		for i in l:
			print(int(i), end='')
		break


year = input()
c = 0
while c < 4:
	year = int(year) + 1
	year = str(year)
	d = len(set(year))
	c = int(d)
print(year)


c = int(input())
d = c + 1
for i in range(10000000000000000000000000000000000000):
	d = str(d)
	if len(set(d)) == len(d):
		print(d)
		break
	else:
		d = int(d) + 1


def razl(n):
	m = {}
	for temp in str(n):
		if temp in m.keys():
			m[temp] += 1
		else:
			m[temp] = 1
	return len(m) == len(str(n))
n = int(input())
m = n + 1
while not razl(m):
	m += 1
print(m)


x = int(input())
y = 0
while y == 0:
	x = x + 1
	c = list(set(str(x)))
	if len(c) == 4:
		print(x)
		y = 1


year = int(input())
year0 = str(year)
none = True
while none:
	year += 1
	year0 = str(year)
	a = 0
	b = 0
	c = 0
	d = 0
	e = 0
	f = 0
	g = 0
	h = 0
	i = 0
	j = 0
	for k in range(4):
		if year0[k] == '0':
			a += 1
		elif year0[k] == '1':
			b += 1
		elif year0[k] == '2':
			c += 1
		elif year0[k] == '3':
			d += 1
		elif year0[k] == '4':
			e += 1
		elif year0[k] == '5':
			f += 1
		elif year0[k] == '6':
			g += 1
		elif year0[k] == '7':
			h += 1
		elif year0[k] == '8':
			i += 1
		elif year0[k] == '9':
			j += 1
	if a <= 1 and b <= 1 and (c <= 1) and (d <= 1) and (e <= 1) and (f <= 1) and (g <= 1) and (h <= 1) and (i <= 1) and (j <= 1):
		none = False
		print(year)


s = int(input())
s = s + 1
while True:
	s = list(str(s))
	s1 = set(s)
	s2 = ''
	for i in s:
		s2 += i
	if len(s1) == len(s):
		print(s2)
		break
	else:
		s = int(s2) + 1
		s2 = s


n = int(input())
for i in range(n + 1, 10 ** 10):
	l = list(map(int, str(i)))
	if len(set(l)) == len(l):
		print(i)
		break


x = int(input())
x = x + 1
u = 0
while u == 0:
	s = str(x)
	i = 0
	p = {'a'}
	l = len(s)
	while i < l:
		p.add(s[i])
		i = i + 1
	if len(p) == 5:
		u = 1
	else:
		x = x + 1
print(x)


def isDistinctDigit(year):
	digitDict = {}
	for each in str(year):
		if each in digitDict.keys():
			return False
		else:
			digitDict[each] = 1
	return True
input_year = int(input())
input_year += 1
while not isDistinctDigit(input_year):
	input_year += 1
print(input_year)


from sys import stdin

def main(r):
	for i in r:
		s = str(i)
		if len(set(s)) == len(s):
			print(s)
			return
main(range(int(stdin.readline()) + 1, 10000000))


def year(n):
	if len(set(list(str(n)))) != 4:
		return False
	else:
		return True
a = int(input()) + 1
while year(a) == False:
	a += 1
	continue
print(a)


n = input()
while True:
	n = int(n)
	n = n + 1
	n = str(n)
	a = n.count(n[0])
	b = n.count(n[1])
	c = n.count(n[2])
	d = n.count(n[3])
	if a == b == c == d == 1:
		print(n)
		quit()


year = int(input())
year = year + 1
year = str(year)
thousand = int(year[0])
hundred = int(year[1])
dozen = int(year[2])
unit = int(year[3])
while thousand == hundred or thousand == dozen or thousand == unit or (hundred == dozen) or (hundred == unit) or (dozen == unit):
	year = int(year)
	year += 1
	year = str(year)
	thousand = int(year[0])
	hundred = int(year[1])
	dozen = int(year[2])
	unit = int(year[3])
print(year)


def isBeautiful(entrada):
	return len(str(entrada)) == len(set(list(str(entrada))))
entrada = int(input())
entrada += 1
while not isBeautiful(entrada):
	entrada += 1
print(entrada)


x = input()
x = str(int(x) + 1)
f = 0
while f == 0:
	a = []
	for i in x:
		if (i in a) == False:
			a.append(i)
	if len(a) == 4:
		f = 1
	else:
		x = str(int(x) + 1)
print(x)


def fun(n):
	r = str(n + 1)
	if len(r) == len(set(list(r))):
		return r
	else:
		return fun(int(r))
print(fun(int(input())))


y = input()
y = int(y) + 1
y = str(y)
b = list(y)
y = int(y)
c = 0
i = 0
a = ''
while len(b) != len(set(b)):
	c = y + i
	b = list(str(c))
	i += 1
a = a.join(b)
print(a)


l = list(input())
x = int(''.join(l))
while True:
	x += 1
	l = list(str(x))
	s = set(l)
	if len(l) == len(s):
		print(x)
		break


def findNumber(n):
	i = n + 1
	while i >= 0:
		count = [0 for i in range(10)]
		x = i
		count1 = 0
		count2 = 0
		while x:
			count[x % 10] += 1
			x = int(x / 10)
			count1 += 1
		for j in range(0, 10, 1):
			if count[j] == 1:
				count2 += 1
		if count1 == count2:
			return i
		i += 1
n = int(input())
print(findNumber(n))


n = int(input())
i = n
while i < 10000:
	i = i + 1
	d = set(list(str(i)))
	if len(d) >= len(str(i)):
		break
print(i)


n = int(input())
for i in range(n + 1, 9999):
	s = []
	for x in range(0, 4):
		s.append(str(i)[x])
	if len(set(s)) == 4:
		print(i)
		break


a = int(input())
b = a + 1
c = str(b)

def f(x):
	t = []
	for i in range(len(x)):
		if x[i] not in t:
			t.append(x[i])
	return len(t)
while f(c) != 4:
	b = b + 1
	c = str(b)
print(b)


start_year = int(input())
year = start_year + 1
while len(set(list(str(year)))) < 4:
	year += 1
print(year)


def dis(y):
	temp = []
	for i in y:
		if i in temp:
			return 0
		else:
			temp.append(i)
	return 1
y = int(input())
stry = str(y)
while True:
	new = y + 1
	strn = str(new)
	if dis(strn):
		print(new)
		break
	else:
		y = y + 1


import collections
y = input()
z = int(y)
while True:
	z += 1
	d = {}
	d = collections.Counter(str(z))
	l = [i for i in d.values()]
	if l == [1, 1, 1, 1]:
		print(z)
		break


def isDistinct(n):
	string = str(n)
	for i in range(len(string)):
		if string.count(string[i]) > 1:
			return False
	return True
y = input()
n = int(y) + 1
while isDistinct(n) == False:
	n += 1
print(n)


import collections

class solution:

	def ans(n):
		count = 0
		for i in range(int(n) + 1, 10000):
			if len(set(str(i))) == len(str(n)) and count < 1:
				count += 1
				return i
n = str(input())
res = solution.ans(n)
print(res)


y = input()
yep = True
count = 0
while yep:
	y_ = int(y)
	y_ += 1
	y = str(y_)
	if y[2] == y[3]:
		continue
	elif y[1] == y[2] or y[1] == y[3]:
		continue
	elif y[0] == y[1] or y[0] == y[2] or y[0] == y[3]:
		continue
	else:
		print(y)
		yep = False


n = input()
n = int(n)
for i in range(n + 1, 90000):
	num = i
	a = num % 10
	num = int(num / 10)
	b = num % 10
	num = int(num / 10)
	c = num % 10
	num = int(num / 10)
	d = num % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		break


import sys
year = int(input().strip())
for i in range(year + 1, 10000):
	if len(set(str(i))) == len(str(year)):
		print(i)
		break


n = int(input())
s = n
while s >= n:
	s = s + 1
	s1 = str(s)
	if s1.count('0') > 1 or s1.count('1') > 1 or s1.count('2') > 1 or (s1.count('3') > 1) or (s1.count('4') > 1) or (s1.count('5') > 1) or (s1.count('6') > 1) or (s1.count('7') > 1) or (s1.count('8') > 1) or (s1.count('9') > 1):
		continue
	else:
		print(s)
		break


n = int(input())
x = n + 1
while x < 10000:
	a = []
	for num in str(x):
		a.append(num)
		b = set(a)
	if len(b) == 4:
		print(x)
		break
	else:
		x += 1


y = int(input())
for i in range(y + 1, 9999):
	a = []
	tmp = i
	for j in range(0, 10):
		a.append(0)
	for j in range(0, 4):
		x = int(tmp % 10)
		a[x] += 1
		tmp = tmp / 10
	flag = 1
	for j in range(0, 10):
		if a[j] > 1:
			flag = 0
	if flag == 1:
		ans = i
		break
print(ans)


s = input()
x = int(s) + 1
while True:
	if len(set(list(str(x)))) == 4:
		print(x)
		exit(0)
	x += 1


def numb_dist(x):
	data = []
	y = list(str(x))
	for v in y:
		if not v in data:
			data.append(v)
	return len(data) == len(y)
y = int(input())
while not numb_dist(y + 1):
	y += 1
print(y + 1)


s = input()
ans = ''
n = int(s) + 1
while n <= 9999:
	s = str(n)
	count = set()
	for i in s:
		count.add(i)
	if len(count) == 4:
		break
	n += 1
print(n)


n = input()
for i in range(int(n) + 1, 99999):
	x = list(str(i))
	z = set(x)
	if len(z) == 4:
		print(''.join(x))
		break


a = int(input())
temp = 0
while temp != 1:
	a = a + 1
	b = str(a)
	c = 0
	for i in range(4):
		for j in range(4):
			if i != j and b[i] != b[j]:
				c += 1
		if c == 12:
			temp = 1
			break
print(a)


i = int(input())
flag = 0
i += 1
while flag == 0:
	s = str(i)
	a = s.count(s[0])
	b = s.count(s[1])
	c = s.count(s[2])
	d = s.count(s[3])
	if a == b == c == d == 1:
		flag = 1
	else:
		i += 1
print(i)


import sys, math

def main():
	entrada = int(input())
	while True:
		entrada = entrada + 1
		digitos = str(entrada)
		if len(digitos) == len(set(digitos)):
			print(entrada, end='')
			exit()
main()


from collections import deque
import math
n = int(input())
isAnswer = False
while isAnswer == False:
	n += 1
	str1 = str(n)
	unicSet = set()
	for i in range(4):
		unicSet.add(str1[i])
	if len(unicSet) == 4:
		isAnswer = True
		print(n)


o = int(input())
orig = o
while True:
	a = []
	n = o
	while n > 0:
		a.append(n % 10)
		n = int(n / 10)
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	if len(b) == 4 and o != orig:
		print(o)
		break
	else:
		o = o + 1


def eq(a, b, c, d):
	return a == b or a == c or a == d or (b == c) or (b == d) or (c == d)

def parcala(year):
	ones = year % 10
	tens = int((year - ones) / 10 % 10)
	hundreds = int((year - tens * 10 - ones) / 100 % 10)
	thousands = int((year - hundreds * 100 - tens * 10 - ones) / 1000 % 10)
	return eq(ones, tens, hundreds, thousands)
year = int(input())
year += 1
while True:
	if parcala(year):
		year += 1
	else:
		print(year)
		break


s = input()
n = int(s)
n = n + 1
while 1:
	s = str(n)
	n1 = s[0]
	n2 = s[1]
	n3 = s[2]
	n4 = s[3]
	if s[0] not in [n2, n3, n4] and s[1] not in [n1, n3, n4] and (s[2] not in [n1, n2, n4]) and (s[3] not in [n1, n2, n3]):
		break
	n = n + 1
print(n)


y = int(input())
a = set()
while len(a) != 4:
	a = set()
	y += 1
	a.update(str(y))
print(y)


n = int(input())
n += 1
while True:
	d4 = n % 10
	d3 = n // 10 % 10
	d2 = n // 100 % 10
	d1 = n // 1000 % 10
	if d1 == d2 or d1 == d3 or d1 == d4 or (d2 == d3) or (d2 == d4) or (d3 == d4):
		n += 1
	else:
		print(n)
		exit()


def ok(x):
	s = str(x)
	for i in range(4):
		for j in range(i + 1, 4):
			if s[i] == s[j]:
				return 0
	return 1
n = int(input())
for i in range(n + 1, 100000):
	if ok(i):
		print(i)
		break


t = int(input())
t = t + 1
h = False
while h == False:
	f = list(str(t))
	H = []
	for x in f:
		if (x in H) == False:
			H.append(x)
	if len(H) == len(f):
		h = True
	else:
		t = t + 1
print(t)


def isDistinct(numb):
	lst = [i for i in range(10)]
	sNumb = str(numb)
	for i in range(len(sNumb)):
		lst[int(sNumb[i])] = -1
	return lst.count(-1) == len(sNumb)
numb = int(input())
numb += 1
while not isDistinct(numb):
	numb += 1
print(numb)


def f(x):
	if len(set(str(x))) != 4:
		return False
	else:
		return True
n = int(input()) + 1
while not f(n):
	n = n + 1
print(n)


n = int(input())
while True:
	n += 1
	s = str(n)
	if s.count(s[0]) == s.count(s[1]) == s.count(s[2]) == s.count(s[3]) == 1:
		print(n)
		break


import math as mt
import sys as sy

class abc:

	def mkl(self):
		n = int(input())
		for i in range(n + 1, 9013):
			l = sorted(list(str(i)))
			if l[0] != l[1] and l[1] != l[2] and (l[2] != l[3]) and (l[3] != l[0]):
				print(i)
				break
b = abc()
b.mkl()


y = int(input())
by = y + 1
while True:
	aux = str(by)
	bs = set(aux)
	if len(bs) == 4:
		break
	by += 1
print(by)


n = int(input())
for i in range(n + 1, 9013):
	count = 0
	for k in str(i):
		if str(i).count(k) == 1:
			count += 1
	if count == 4:
		print(i)
		exit(0)


n = int(input())
for i in range(n + 1, 10000):
	m = i
	a = []
	while m > 0:
		d = m % 10
		m = m // 10
		a.append(d)
	b = []
	for j in a:
		if j not in b:
			b.append(j)
	if a == b:
		print(i)
		break


i = int(input())
while True:
	i += 1
	j = i
	hash = [False] * 10
	f = False
	while j != 0:
		r = int(j % 10)
		if hash[r] == False:
			hash[r] = True
		else:
			f = True
			break
		j = int(j / 10)
	if f == False:
		break
print(i)


year = int(input()) + 1

def isuniq(num):
	str_num = str(num)
	for d in str_num:
		if str_num.count(d) == 1:
			continue
		else:
			return False
	return True
while not isuniq(year):
	year += 1
print(year)


def isdistinct(n):
	h = str(n)
	f = True
	for i in h:
		if h.count(i) > 1:
			f = False
	return f
k = input()
y = int(k)
while y != 0:
	y += 1
	if isdistinct(y):
		print(y)
		break


n = int(input())

def isDistinct(n):
	counter = []
	for c in n:
		if c not in counter:
			counter.append(c)
		else:
			return False
	return True
while True:
	n = n + 1
	if isDistinct(str(n)):
		print(n)
		break


print([x for x in range(int(input()) + 1, 9013) if len(set(str(x))) == 4][0])


def isUnique(str):
	a = list(str)
	n = len(a)
	for i in range(n):
		if str.count(a[i]) != 1:
			return False
			break
	return True
s = input()
n = str(int(s) + 1)
while 1:
	if isUnique(n) == True:
		print(n)
		break
	else:
		n = str(int(n) + 1)


n = int(input())
while True:
	n += 1
	l = []
	i = n
	while i:
		if i % 10 in l:
			break
		l.append(i % 10)
		i //= 10
	if len(l) == 4:
		print(n)
		break


line = input()
check = False
year = int(line)
year += 1
while check is False:
	my_set = set(str(year))
	if len(my_set) == 4:
		check = True
		break
	else:
		year += 1
print(str(year))


N = int(input())
while True:
	n = list(str(N + 1))
	n.sort()
	i = 0
	s = 0
	while i < len(n) - 1:
		if n[i] == n[i + 1]:
			s += 1
		elif n[i] != n[i + 1]:
			s += 0
		i += 1
	if s == 0:
		break
	N += 1
print(N + 1)


print(next((a for a in range(int(input()) + 1, 9013) if len(set(str(a))) == 4)))


n = int(input())
x = True
m = n
while x:
	y = 0
	m += 1
	for i in range(len(str(m))):
		for j in range(len(str(m))):
			if i != j and str(m)[i] == str(m)[j]:
				y = 1
	if y == 0:
		x = False
print(m)


a = int(input())
done = False
while not done:
	a += 1
	li = []
	for i in str(a):
		if i in li:
			pass
		else:
			li.append(i)
		if len(li) == len(str(a)):
			done = True
print(a)


n = int(input())
f = True
while f:
	n = int(n)
	n += 1
	n = str(n)
	l = []
	for i in range(4):
		l.append(n[i])
	if len(set(l)) == 4:
		f = False
		break
print(n)


a = True
n = input()
b = n
while a == True:
	dig = []
	i = 0
	b = str(int(b) + 1)
	while i < 4:
		dig.append(b[i])
		i = i + 1
	if dig.index(dig[1]) == 1 and dig.index(dig[2]) == 2 and (dig.index(dig[3]) == 3):
		a = False
print(b)


def all_different(year):
	s = ''.join(sorted(str(year)))
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			return False
	return True
year = int(input())
year += 1
while not all_different(year):
	year += 1
print(year)


x = int(input())
a = set()
i = x + 1
while True:
	for l in str(i):
		a.add(l)
	if len(a) == len(str(i)):
		break
	i += 1
	a = set()
print(i)


y = int(input()) + 1
num = y
while 1:
	list = []
	for x in range(1, 5):
		list.append(int(y % 10))
		y = int(y / 10)
	count = 0
	for a in list:
		for b in list:
			if a != b:
				count += 1
	if count == 12:
		break
	num += 1
	y = num
print(num)


def krasGod(n):
	while True:
		n += 1
		if len(set(str(n))) == 4:
			break
	return n
print(krasGod(int(input())))


year1 = int(input())
year2 = str(year1 + 1)
while year2.count(year2[0]) > 1 or year2.count(year2[1]) > 1 or year2.count(year2[3]) > 1:
	year2 = str(int(year2) + 1)
print(year2)


n = int(input())
n += 1
l = []
t = n
while t > 0:
	if t % 10 not in l:
		l.append(t % 10)
		t = t // 10
	elif t % 10 in l:
		n += 1
		t = n
		l.clear()
print(n)


s = int(input())
ans = set()
while 1:
	s += 1
	k = str(s)
	ans.clear()
	ans.add(k[0])
	ans.add(k[1])
	ans.add(k[2])
	ans.add(k[3])
	if len(ans) == 4:
		break
print(s)


def distinct(m):
	n = list(map(int, str(m)))
	a = set()
	for i in n:
		a.add(i)
	if len(a) == 4:
		return 1
	else:
		return 0
n = int(input())
while 1:
	n += 1
	if distinct(n):
		print(n)
		break


n = int(input())
n = n + 1
f = 1
while f == 1:
	n1 = n
	s = 0
	a = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
	while n1 != 0:
		a[n1 % 10] -= 1
		n1 = n1 // 10
	for i in range(10):
		if a[i] < 0:
			n = n + 1
			s = s + 1
			break
	if s == 0:
		print(n)
		f = 0
		break


def main():
	n = int(input())

	def checker(a):
		l = list(str(a))
		s = set(l)
		if len(s) == len(l):
			return 1
		return 0
	while 1:
		n += 1
		if checker(n):
			print(n)
			return 0
	return 0
main()


n = int(input())

def verificar(s):
	diferente = False
	for i in range(4):
		for j in range(i + 1, 4):
			if i != j:
				if s[i] == s[j]:
					diferente = True
	return diferente
n += 1
while True:
	if verificar(str(n)) == True:
		n += 1
	else:
		print(n)
		break


y = input()
num = int(y) + 1
year = '' + str(num)

def check(x):
	_size = len(x)
	repeated = []
	flag = 0
	for i in range(_size):
		k = i + 1
		for j in range(k, _size):
			if x[i] == x[j] and x[i] not in repeated:
				flag = 1
				break
		if flag == 1:
			break
	return flag
while True:
	if check(year) == 1:
		num = num + 1
		year = '' + str(num)
	else:
		print(year)
		break


no = int(input())
for i in range(9000):
	no = no + 1
	no = str(no)
	if no[0] != no[1] and no[0] != no[2] and (no[0] != no[3]) and (no[1] != no[2]) and (no[1] != no[3]) and (no[2] != no[3]) and (no[3] != no[1]):
		print(no)
		break
	no = int(no)


n = int(input())
while True:
	n = n + 1
	n1 = [i for i in str(n)]
	if n1[0] not in n1[1:] and n1[1] not in n1[2:] and (n1[2] not in n1[3:]):
		print(n)
		break


n = int(input())
f = True
while f:
	n += 1
	a = {int(x) for x in str(n)}
	if len(a) == 4:
		f = False
print(n)


n = int(input())
running = True
while running:
	n = n + 1
	line = list(str(n))[:]
	if len(line) == len(set(line)):
		running = False
print(n)


n = int(input())

def are_digits_distinct(num):
	num_as_str = str(num)
	for i in range(len(num_as_str) - 1):
		cur = num_as_str[i]
		for j in range(i + 1, len(num_as_str)):
			if cur == num_as_str[j]:
				return False
	return True
for num in range(n + 1, 10000):
	if are_digits_distinct(num):
		print(num)
		break


year = input()
year = str(int(year) + 1)
k = 0
while True:
	if len(set(year)) < len(year):
		year = str(int(year) + 1)
	else:
		break
print(year)


def digits(num):
	return [d for d in str(num)]

def check_distinct(num):
	digs = digits(num)
	for (i, d) in enumerate(digs):
		for (j, dd) in enumerate(digs):
			if i != j and d == dd:
				return False
	return True
n = int(input())
n += 1
while not check_distinct(n):
	n += 1
print(n)


n = int(input())
for i in range(n + 1, 9100):
	temp = i
	s = set()
	while temp:
		s.add(temp % 10)
		temp //= 10
	if len(s) == 4:
		print(i)
		break


n = int(input())
c = 0
while 1:
	n = n + 1
	val = n
	l = list(map(int, str(n)))
	a = len(l)
	b = []
	for i in l:
		if i not in b:
			b.append(i)
	m = len(b)
	if a == m:
		print(val)
		break


y = int(input())
y += 1
while True:
	if y % 10 != int(y / 10) % 10 and y % 10 != int(y / 100) % 10 and (y % 10 != int(y / 1000) % 10):
		if int(y / 10) % 10 != int(y / 100) % 10 and int(y / 10) % 10 != int(y / 1000) % 10:
			if int(y / 100) % 10 != int(y / 1000) % 10:
				print(y)
				break
	y += 1


import sys
y = int(input()) + 1
while True:
	y = str(y)
	a = list(y)
	if len(a) == len(set(a)):
		print(y)
		sys.exit(0)
	else:
		y = int(y)
		y += 1


year = input()
c = 0
year = int(year)
year += 1
year = str(year)
while year <= '9012':
	for i in year:
		for j in year:
			if i == j:
				c += 1
	if c != 4:
		year = int(year)
		year += 1
		year = str(year)
		c = 0
	else:
		break
print(year)


number = int(input())
stop = False
while not stop:
	number += 1
	if number // 1000 != number % 10 and number // 1000 != number // 100 % 10 and (number // 1000 != number // 10 % 10) and (number % 10 != number // 100 % 10) and (number % 10 != number // 10 % 10) and (number // 100 % 10 != number % 10) and (number // 100 % 10 != number // 10 % 10) and (number // 10 % 10 != number % 10):
		print(number)
		stop = True


def createCheckerSet(year):
	return set(str(year))

def main():
	inputYear = int(input())
	inputYear += 1
	checkerSet = createCheckerSet(inputYear)
	while len(checkerSet) != 4:
		inputYear += 1
		checkerSet = createCheckerSet(inputYear)
	print(inputYear)
main()


n = int(input())

def unique(n):
	return len(set(str(n)))

def length(n):
	return len(str(n))
d = n + 1
while length(d) != unique(d):
	d = d + 1
print(d)


a = input()
for i in range(int(a) + 1, 20000):
	b = dict.fromkeys(str(i))
	if len(b) == 4:
		print(i)
		break


currentyear = int(input()) + 1
while len(str(currentyear)) > len(set(str(currentyear))):
	currentyear += 1
print(currentyear)


def cons(ch):
	j = 0
	w = True
	while j < len(ch):
		for i in range(0, len(ch)):
			if ch[i] == ch[j] and i != j:
				w = False
		j = j + 1
	return w
x = int(input())
s = str(x + 1)
while not cons(s):
	s = str(int(s) + 1)
print(s)


def checkBeautifulYear(yearN):
	yearN = str(yearN)
	if yearN[0] in yearN[1:]:
		return False
	if yearN[1] in yearN[0] + yearN[2:]:
		return False
	if yearN[2] in yearN[:2] + yearN[3]:
		return False
	if yearN[3] in yearN[:3]:
		return False
	return True
yearN = int(input())
while True:
	yearN = yearN + 1
	if checkBeautifulYear(yearN):
		print(yearN)
		break


sYear = str(input())
while True:
	sYear = str(int(sYear) + 1)
	if sYear.count(sYear[0]) == 1 and sYear.count(sYear[1]) == 1 and (sYear.count(sYear[2]) == 1):
		print(sYear)
		break


def destinct(n):
	s = str(n)
	st = set()
	for c in s:
		st.add(c)
	if len(st) == 4:
		return True
	else:
		return False
y = int(input())
while True:
	y = y + 1
	if destinct(y):
		print(y)
		break


def dist(n):
	a = n % 10
	b = int(n / 10) % 10
	c = int(n / 100) % 10
	d = int(n / 1000) % 10
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		return False
	else:
		return True
y = int(input())
flag = False
while not flag:
	y += 1
	if dist(y):
		flag = True
print(y)


n = int(input())
i = n + 1
while 1:
	j = i
	a = []
	while j:
		a.append(j % 10)
		j = j // 10
	b = set(a)
	if len(a) == len(b):
		print(i)
		break
	else:
		i = i + 1


n = int(input())
n += 1
while True:
	(x, flag) = (set(), 0)
	for i in str(n):
		if i in x:
			flag = 1
			break
		x.add(i)
	if flag == 0:
		print(n)
		break
	n += 1


a = int(input())
for i in range(1, 9000):
	b = a + i
	c = '' + str(b)
	x = list(c)
	if x[0] != x[1] != x[2] != x[3] != x[1] and x[0] != x[3] and (x[0] != x[2]):
		print(int(c))
		break


begin = int(input()) + 1

def check():
	global alist
	global begin
	alist = [True] * 10
	for i in range(0, 4):
		ok = int(str(begin)[i])
		if alist[ok]:
			alist[ok] = False
		else:
			begin += 1
			check()
			break
check()
print(begin)


number = int(input()) + 1
while True:
	number_found = True
	for i in range(len(str(number)) - 1):
		if str(number)[i] in str(number)[i + 1:]:
			number_found = False
			break
	if number_found:
		print(number)
		break
	number += 1


year = int(input()) + 1
while set(str(year)).__len__() < 4:
	year += 1
print(year)


a = int(input().strip().split()[0])
j = a + 1
while True:
	b = [str(j)[i] for i in range(4)]
	b.sort()
	if b[0] != b[1] and b[0] != b[1] and (b[1] != b[2]) and (b[2] != b[3]):
		print(j)
		break
	j = j + 1


n = int(input())
q = 5
while q == 5:
	n += 1
	mn = set()
	s = str(n)
	for i in range(len(s)):
		mn.add(s[i])
	if len(mn) == len(s):
		print(n)
		q = 3


n = int(input())
res = n + 1
lres_set = set(str(res))
while True:
	if len(lres_set) == 4:
		print(res)
		break
	else:
		res += 1
		lres_set = set(str(res))


def isDistinct(n):
	n = str(n)
	l = 0
	for i in n:
		if n.count(i) == 1:
			l += 1
	if l == len(n):
		return True
	return False
n = int(input())
n += 1
while True:
	if isDistinct(n):
		print(n)
		break
	else:
		n += 1


n = int(input())
n += 1
while n <= 10000:
	year = [c for c in str(n)]
	if len(set(year)) == 4:
		print(n)
		break
	n += 1


n = int(input())
for i in range(n + 1, 9050):
	h = {}
	temp = i
	while temp > 0:
		d = temp % 10
		temp = temp // 10
		if h.setdefault(d) == None:
			h.update({d: 1})
		else:
			val = h.get(d) + 1
			h.update({d: val})
	if len(h) == 4:
		print(i)
		break


a = int(input())
t = 1
a = a + 1
while t != 0:
	b = set(str(a))
	if len(b) == 4:
		print(a)
		t = 0
	else:
		a = a + 1
		t = 1


n = input()
while True:
	stat = 'null'
	n = int(n)
	n += 1
	n = str(n)
	for i in range(10):
		if n.count(str(i)) >= 2:
			stat = 'done'
			break
	if stat != 'done':
		break
print(n)


year = input()
int_year = int(year) + 1
str_year = str(int_year)

def is_distinct(y):
	l = ''
	for i in y:
		if i not in l:
			l += i
	return l == y
while not is_distinct(str_year):
	int_year += 1
	str_year = str(int_year)
print(str_year)


import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def is_distinct(n):
	s = str(n)
	st = set(s)
	if len(st) == len(s):
		return True
	return False
n = inp()
y = n + 1
while True:
	if is_distinct(y):
		print(y)
		break
	y += 1


y = int(input('')) + 1
ys = str(y)
while any((ys.count(i) > 1 for i in ys)):
	y += 1
	ys = str(y)
print(y)


s = input()
isnotGucci = True
while isnotGucci:
	s = str(int(s) + 1)
	isnotGucci = False
	for i in range(3):
		for j in range(i + 1, 4):
			if s[i] == s[j]:
				isnotGucci = True
print(s)


y = int(input())
a = 0
while a == 0:
	y = y + 1
	s = str(y)
	s = list(s)
	s.sort()
	if int(s[0]) < int(s[1]) < int(s[2]) < int(s[3]):
		a = 1
	else:
		a = 0
print(y)


import array
a = array.array('i', [0, 0, 0, 0])
n = int(input())
temp = n
flag = 0
while flag == 0:
	n += 1
	temp = n
	j = 0
	while temp != 0:
		a[j] = temp % 10
		temp = temp // 10
		j += 1
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		flag = 1
print(n)


n = int(input())
for i in range(n + 1, 9876):
	s = {x for x in str(i)}
	if len(s) == 4:
		print(i)
		break


n = input()
for i in range(int(n) + 1, 100000):
	q = str(i)
	prove = True
	for el in q:
		if q.count(el) > 1:
			prove = False
			break
	if prove:
		print(i)
		exit(0)


def checkYear(sample):
	sample = str(sample)
	size = len(sample)
	for i in range(size):
		for j in range(i + 1, size):
			if sample[i] == sample[j]:
				return False
	return True

def beautifulYear():
	r = int(input())
	while True:
		r = r + 1
		if checkYear(r):
			print(r)
			return
beautifulYear()


n = int(input())
c = 0
temp = n
while n > 0:
	l = []
	n = n + 1
	temp = n
	while temp > 0:
		l.append(temp % 10)
		temp = temp // 10
	if len(l) == len(set(l)):
		print(n)
		break


def f(n):
	n = list(str(n))
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		return True
	else:
		return False
n = int(input())
for i in range(n + 1, 9210):
	if f(i):
		print(i)
		break


def isdistinct(n):
	l = []
	lst = [int(i) for i in str(n)]
	[[l.append(i) if i not in l else i] for i in lst]
	return True if l == lst else False
n = int(input())
while True:
	n = n + 1
	if isdistinct(n):
		print(n)
		break


year = int(input())

def checkunique(num):
	num = str(num)
	for i in num:
		if num.count(i) != 1:
			return False
	return True
year += 1
while year:
	if checkunique(year):
		print(year)
		break
	year += 1


A = int(input())
A += 1
while len(set(str(A))) < 4:
	A += 1
print(A)


n = int(input()) + 1
while True:
	a = list(map(int, str(n).strip()))
	z = list(set(a))
	if len(a) == len(z):
		print(n)
		break
	n += 1


import math
g = lambda x: map(x, input().split())

def dig(n):
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			if n[i] == n[j]:
				return False
	return True

def main():
	n = int(input())
	n += 1
	while n <= 10 ** 5:
		x = dig(str(n))
		if x:
			return n
		n += 1
print(main())


import collections
y = int(input())
x = 0
while True:
	y = y + 1
	s = str(y)
	for j in s:
		count = dict(collections.Counter(s))
		if count[j] == 1:
			x = x + 1
			if x == 4:
				print(int(s))
				break
		else:
			x = 0
			break
	if x == 4:
		break


def is_distinct_year(year_a):
	list = []
	str_year = str(year_a)
	for i in str_year:
		if i in list:
			return False
		else:
			list.append(i)
	return True
year = int(input())
while True:
	year = year + 1
	if is_distinct_year(year):
		print(year)
		break


s = int(input())
for i in range(1, 8001):
	s = s + 1
	n = str(s)
	if n[0] != n[1] and n[0] != n[2] and (n[0] != n[3]) and (n[1] != n[2]) and (n[1] != n[3]) and (n[2] != n[3]):
		print(n)
		break


year = str(input())
years = int(year) + 1
years = str(years)
while years.count('0') > 1 or years.count('1') > 1 or years.count('2') > 1 or (years.count('3') > 1) or (years.count('4') > 1) or (years.count('5') > 1) or (years.count('6') > 1) or (years.count('7') > 1) or (years.count('8') > 1) or (years.count('9') > 1):
	years = int(years) + 1
	years = str(years)
print(years)


start = int(input()) + 1
starts = str(start)
while len(set(starts)) < len(starts):
	start = start + 1
	starts = str(start)
print(start)


y = int(input())
ok = 1
while ok:
	ok = 0
	y += 1
	c = str(y)
	if c[0] == c[1] or c[0] == c[2] or c[0] == c[3] or (c[1] == c[2]) or (c[1] == c[3]) or (c[2] == c[3]):
		ok = 1
print(y)


n = int(input())
n += 1
while True:
	nss = [i for i in str(n)]
	if len(set(nss)) == 4:
		print(n)
		break
	else:
		n += 1


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def solve(n):

	def is_unique(num):
		s = set()
		for c in num:
			if c in s:
				return False
			s.add(c)
		return True
	while True:
		if is_unique(str(n)):
			return n
		n += 1
n = inp()
print(solve(n + 1))


n = int(input())
while 1:
	n += 1
	s = set()
	for x in str(n):
		s.add(x)
	if len(s) == 4:
		print(n)
		break


y = int(input())
distinct = False
while not distinct:
	y += 1
	s = str(y)
	l = list()
	for i in s:
		if i not in l:
			l.append(i)
	if len(l) == 4:
		print(s)
		break


s = int(input())
s += 1
f = str(s)
while f[0] == f[1] or f[0] == f[2] or f[0] == f[3] or (f[1] == f[2]) or (f[1] == f[3]) or (f[2] == f[3]):
	s += 1
	f = str(s)
print(s)


y = int(input())
while True:
	y += 1
	a = set(str(y))
	if len(a) == 4:
		print(str(y))
		exit(0)


def is_good(year):
	y = str(year)
	s = set()
	for c in y:
		s.add(c)
	return len(s) == 4
n = int(input().strip('\n\r\t '))
for k in range(n + 1, 10000):
	if is_good(k):
		print(k)
		break


n = int(input())
while 1:
	n = n + 1
	s = str(n)
	ar = list(s)
	a = ar[0]
	b = ar[1]
	c = ar[2]
	d = ar[3]
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(n)


n = int(input())
m = n + 1
while True:
	a = str(n)
	b = str(m)
	s = set(b)
	if len(s) == len(a):
		print(m)
		exit()
	m += 1


num = int(input())

def distinct(n):
	if len(set(str(n))) == 4:
		return True
	return False
num = num + 1
while not distinct(num):
	num = num + 1
print(num)


ip = str(int(input()) + 1)
c = 0
while c != 1:
	i1 = set(ip)
	if len(i1) == len(ip):
		print(ip)
		c = 1
	else:
		ip = str(int(ip) + 1)


n = input()
a = set(n)
for i in range(1000, 100000):
	k = str(i)
	if len(set(k)) == 4:
		if int(n) >= 1000 and int(n) <= 9000:
			if i > int(n):
				print(i)
				break
		else:
			print('0')
			break


y = int(input())
for i in range(y + 1, 9015):
	l = set()
	s = str(i)
	for j in s:
		l.add(int(j))
	if len(l) == 4:
		print(i)
		break


s = [i for i in range(1000, 9013) if len(set(str(i))) == 4]
n = int(input(''))
print(min((s[i] for i in range(0, len(s)) if s[i] > n)))


n = int(input()) + 1

def check(n):
	s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while n > 0:
		s[n % 10] += 1
		if s[n % 10] == 2:
			return False
		n = n // 10
	return True
while not check(n):
	n += 1
print(n)


year = int(input())
candidate = year
valid_candidate = False
while not valid_candidate:
	candidate = candidate + 1
	candidate_str = str(candidate)
	if candidate_str[0] != candidate_str[1] and candidate_str[0] != candidate_str[2] and (candidate_str[0] != candidate_str[3]) and (candidate_str[1] != candidate_str[2]) and (candidate_str[1] != candidate_str[3]) and (candidate_str[2] != candidate_str[3]):
		valid_candidate = True
print(candidate)


t = int(input())
g = []
for i in range(1000, 9100):
	k = 10
	flag = 0
	d = [0, 0, 0, 0]
	m = i
	for j in range(4):
		d[j] = m % k
		m = m // 10
	d.sort()
	for j in range(1, 4):
		if d[j] == d[j - 1]:
			flag = 1
			break
	if flag == 0:
		g.append(i)
i = 0
while True:
	if g[i] > t:
		print(g[i])
		break
	i += 1


y = int(input())
y += 1
while y % 10 == y // 10 % 10 or y % 10 == y // 100 % 10 or y % 10 == y // 1000 or (y // 10 % 10 == y // 100 % 10) or (y // 10 % 10 == y // 1000) or (y // 100 % 10 == y // 1000):
	y += 1
print(y)


n = int(input())
(v, z) = (0, 0)
while 1:
	n += 1
	a = str(n)
	n1 = n
	while n1 > 0:
		d = n1 % 10
		v += a.count(str(d))
		z += 1
		n1 //= 10
	if z == v:
		print(n)
		break
	else:
		(z, v) = (0, 0)


a = int(input())
z = 0
while z == 0:
	a += 1
	b = list(str(a))
	c = set(b)
	if len(b) == len(c):
		print(a)
		z = 1


year = int(input()) + 1
year = str(year)
solve = set()
while True:
	for i in range(len(year)):
		solve.add(year[i])
	if len(solve) == 4:
		print(year)
		break
	else:
		year = int(year) + 1
		year = str(year)
		solve.clear()


y = int(input())

def nextYear(y):
	for i in range(y + 1, 9013):
		i = str(i)
		i = list(i)
		if i[0] != i[1]:
			if i[0] != i[2]:
				if i[0] != i[3]:
					if i[1] != i[2]:
						if i[1] != i[3]:
							if i[2] != i[3]:
								print(''.join(i))
								break
nextYear(y)


n = int(input())
while True:
	n = n + 1
	n = str(n)
	l = []
	for i in n:
		if i not in l:
			l.append(i)
	p = ''.join(l)
	if p == n:
		print(p)
		break
	else:
		n = int(n)


a = int(input()) + 1
while True:
	z = []
	distinct = True
	for n in str(a):
		if n in z:
			distinct = False
			break
		z.append(n)
	if distinct == True:
		break
	a += 1
print(a)


y = int(input())
(x1, x2) = (y + 1, y + 1)
while 1 > 0:
	s = len(str(x1))
	L = []
	for i in range(s):
		a = int(x1 % 10)
		x1 = int(x1 // 10)
		L.append(a)
	set1 = set([])
	for j in range(s):
		set1.add(int(L[j]))
	s1 = len(set1)
	if s1 == s:
		print(x2)
		break
	else:
		x2 += 1
		x1 = x2


import sys
a = input()
x = int(a) + 1
while True:
	if len(set(str(x))) == 4:
		print(x)
		sys.exit()
	x += 1


s = int(input())
a = str(s + 1)
while len(set(list(a))) != 4:
	a = str(eval(a) + 1)
print(a)


import sys
data = sys.stdin.readlines()
final_data = int(data[0])

def check(number):
	checker = True
	db = []
	for item in str(number):
		if item not in db:
			db += [item]
		else:
			checker = False
			break
	return checker
final_data += 1
while check(final_data) == False:
	final_data += 1
print(final_data)


def Happy(y):
	r = []
	while y != 0:
		t = y % 10
		if t in r:
			return False
		else:
			r.append(t)
		y //= 10
	return True
n = int(input())
t = 0
for i in range(n + 1, 10001):
	if Happy(i):
		t = i
		break
print(t)


year = int(input())

def check(y):
	if len(str(y)) == len(set(str(y))):
		return 1
	return 0

def main():
	next_year = year + 1
	while 1:
		if check(next_year):
			print(next_year)
			break
		else:
			next_year += 1
if __name__ == '__main__' and year >= 1000 and (year <= 9000):
	main()


import sys
n = int(input())
for i in range(n + 1, sys.maxsize):
	a = str(i)
	c = len(a)
	b = len(set(list(str(i))))
	if c == b:
		print(i)
		break


t = 1 + int(input())

def same_digits(t):
	arr = []
	while t != 0:
		arr.append(t % 10)
		t = int(t / 10)
	if len(set(arr)) == len(arr):
		return True
	else:
		return False
while not same_digits(t):
	t += 1
print(t)


year = int(input())
while True:
	year += 1
	if all([1 if str(year).count(i) == 1 else 0 for i in str(year)]):
		print(year)
		break


def distinct(year):
	if len(set([s for s in str(year)])) == 4:
		return True
	return False
year = int(input())
year += 1
while not distinct(year):
	year += 1
print(year)


n = int(input())
for k in range(n + 1, 11000):
	t = [0] * 10
	s = k
	while s != 0:
		t[s % 10] += 1
		s //= 10
	l = True
	for i in t:
		if i > 1:
			l = False
	if l:
		print(k)
		break


year = int(input())
for i in range(year + 1, 10000):
	years = str(i)
	numbers = []
	for k in range(4):
		numbers.append(str(i)[k])
	number = set(numbers)
	if len(number) == 4:
		print(i)
		break


x = int(input())
for i in range(x + 1, 100000):
	s = str(i)
	o = s[0]
	t = s[1]
	th = s[2]
	f = s[3]
	if (o != t and o != th and (o != f)) and (o != t and t != th and (t != f)) and (th != t and o != th and (th != f)) and (f != t and f != th and (o != f)):
		print(int(s))
		break


yr = int(input())
while True:
	yr += 1
	if len(str(yr)) == len(set(str(yr))):
		print(yr)
		break


y = int(input())
while 1:
	a = set()
	y += 1
	y = str(y)
	for i in y:
		a.add(int(i))
	if len(a) == 4:
		print(int(y))
		break
	else:
		y = int(y)


ip = input()
n = int(ip) + 1
while len(set(str(n))) != 4:
	n = int(n) + 1
print(n)


def IsDistinct(x):
	t = str(x)
	l = len(t)
	for i in range(l - 1):
		for j in range(i + 1, l):
			if t[i] == t[j]:
				return False
	return True
year = int(input()) + 1
while not IsDistinct(year):
	year += 1
print(year)


n = int(input())
m = str(n)
s = 0
while s != 4:
	s = 0
	n = n + 1
	m = str(n)
	for i in m:
		s += m.count(i)
print(n)


y = int(input())
t = 0
while t == 0:
	y = y + 1
	s = str(y)
	i = 0
	while i < 4:
		if s.count(s[i]) == 1:
			i = i + 1
			t = 1
		else:
			t = 0
			break
print(y)


y = int(input())
k = 0
while k == 0:
	y += 1
	a = list(str(y))
	if a[0] != a[1] and a[0] != a[2] and (a[0] != a[3]) and (a[1] != a[2]) and (a[1] != a[3]) and (a[2] != a[3]):
		k += 1
print(y)


s = int(input())
t = str(s)
r = list(t)
for i in range(s + 1, 10000):
	k = set(list(str(i)))
	if len(k) == 4:
		print(i)
		break


def year(n):
	for year in range(n + 1, 10000):
		hs = set()
		l = [int(x) for x in str(year)]
		hs = set(l)
		if len(hs) == 4:
			return year
n = int(input())
print(year(n))


a = input()
b = int(a)
b = b + 1
c = list(str(b))
while True:
	d = set(c)
	if len(c) == len(d):
		print(''.join(c))
		break
	b = b + 1
	c = list(str(b))


n = int(input())
for r in range(1, 1000):
	p = n + r
	x = str(p)
	y = set(x)
	if len(x) == len(y):
		break
print(p)


y = int(input())
y1 = y
c = -1
while c == -1:
	y1 += 1
	c = 0
	l = list(str(y1))
	l.sort()
	for i in range(3):
		if l[i] == l[i + 1]:
			c = -1
print(y1)


n = input()
y = int(n)
k = False
while k == False:
	y = y + 1
	if len(set(str(y))) == len(n):
		k = True
print(y)


year = int(input())
MAX = 9000
MIX = 1000

def is_year_distinct(year: int) -> bool:
	x = set()
	for c in str(year):
		if c in x:
			return False
		x.add(c)
	return True

def solution(year: int) -> int:
	for y in range(year + 1, MAX + MIX):
		if is_year_distinct(y):
			return y
	return False
print(solution(year))


while True:
	year = int(input())
	if 1000 <= year <= 9000:
		break
year += 1
st = str(year)
test = False
l = []
while test != True:
	for i in st:
		l.append(i)
	b = set(l)
	if len(b) == len(st):
		test = True
	else:
		year += 1
		st = str(year)
		l = []
print(year)


n = int(input())
s = 1
t = int(n)
while s:
	t += 1
	l = list(str(t))
	if len(set(l)) == 4:
		s = 0
print(t)


ye = input()
ye = str(int(ye) + 1)
while len(set(str(ye))) != 4:
	ye = int(ye) + 1
print(ye)


year = input()
num = int(year)
year = list(year)
old_year = year[:]
ist = year[0]
ond = year[1]
ird = year[2]
rth = year[3]
ok = True
while ok:
	num += 1
	year = list(str(num))
	ist = year[0]
	ond = year[1]
	ird = year[2]
	rth = year[3]
	if ist != ond and ist != ird and (ist != rth) and (ond != ird) and (ond != rth) and (ird != rth):
		ok = False
new_year = ''.join(year)
print(new_year)


n = int(input())
c = n + 1
while len(set(str(c))) < 4:
	c = c + 1
print(c)


t1 = input()
t1 = int(t1)
t2 = int(t1)
for a in range(101):
	t2 = t2 + 1
	a = int(t2 / 1000)
	b = int(t2 / 100 % 10)
	c = int(t2 / 10 % 10)
	d = int(t2 % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(t2)
		break


def check_uniq_digits(num):
	a = num % 10
	num //= 10
	b = num % 10
	num //= 10
	c = num % 10
	num //= 10
	d = num
	return (a != b and a != c and (a != d)) and (b != c and b != d) and (c != d)
year = input('')
year = int(year)
year += 1
while not check_uniq_digits(year):
	year += 1
print(year)


a = int(input())
i = a + 1
while 1:
	b = set(list(str(i)))
	if len(b) == 4:
		print(i)
		break
	else:
		i += 1


def year(n):
	lst = []
	while n > 0:
		r = n % 10
		lst.append(r)
		n = n // 10
	for i in range(len(lst)):
		if lst.count(lst[i]) != 1:
			return 0
	return 1
n = int(input())
for i in range(n + 1, 9013):
	if year(i) == 1:
		break
print(i)


y = int(input())
nextYear = y + 1

def digits_are_distinct(num):
	isDistinct = True
	for i in str(num):
		if str(num).count(i) > 1:
			isDistinct = False
			break
	return isDistinct
while not digits_are_distinct(nextYear):
	nextYear += 1
print(nextYear)


t = int(input())
while t != 0:
	t = t + 1
	s = set(str(t))
	if len(s) == 4:
		break
print(t)


import sys

def get():
	return int(sys.stdin.readline().strip())

def ret(n):
	k = list(n)
	for i in n:
		if k.count(i) > 1:
			return 0
	return 1
n = get()
while True:
	n += 1
	if ret(str(n)):
		print(n)
		break


a = input('')
datalen = len(a)
i = a
while int(i) > 0:
	temp_list = []
	for j in str(int(i) + 1):
		if j not in temp_list:
			temp_list.append(j)
	if datalen == len(temp_list):
		print(int(i) + 1)
		break
	else:
		i = int(i) + 1


n = int(input())
for i in range(n + 1, 10000):
	count = [0 for i in range(10)]
	temp = str(i)
	length = len(temp)
	for j in range(length):
		if count[ord(temp[j]) - 48] == 0:
			count[ord(temp[j]) - 48] += 1
		else:
			break
	else:
		print(i)
		break


import math

def num2digits(num):
	i = 0
	digits = []
	while num > 0:
		digits.append(i)
		digits[i] = num % 10
		num = math.floor(num / 10)
		i = i + 1
	return digits
n = int(input())
while 1:
	n = n + 1
	digits = num2digits(n)
	digits.sort()
	flag = 1
	for i in range(1, len(digits)):
		if digits[i] == digits[i - 1]:
			flag = 0
			break
	if flag > 0:
		break
print(n)


def cqw(v):
	t = v
	b = str(t)
	b = [x for x in b]
	b = [*map(int, b)]
	c = list(set(b))
	if len(c) == len(b):
		print(t)
	else:
		cqw(t + 1)
n = int(input())
cqw(n + 1)


n = int(input())
t = 0
r = n + 1
while t == 0:
	y = 0
	for i in range(len(str(r))):
		if str(r).count(str(r)[i]) > 1:
			y = 1
	if y == 0:
		print(r)
		t = 1
		break
	r = r + 1


def dstnct(n):
	st = set()
	ct = 0
	while n != 0:
		st.add(n % 10)
		n = n // 10
		ct += 1
	if ct == len(st):
		return True
	else:
		return False
n = int(input())
c = n
while True:
	c += 1
	if dstnct(c):
		print(c)
		break


y = int(input())
y = y + 1
while True:
	s = str(y)
	count = 0
	for i in range(len(s)):
		count += s.count(s[i])
	if count != 4:
		y += 1
	else:
		break
print(y)


n = int(input())
n += 1
ans = 1
while ans == 1:
	l = [i for i in str(n)]
	v = 1
	for j in l:
		if l.count(j) >= 2:
			v = 0
		if v == 0:
			n += 1
			break
	if v == 1:
		ans = 0
		break
print(n)


y = input()
x = int(y) + 1
y = str(x)
while len({*y}) != 4:
	y = str(x)
	x += 1
print(y)


year = input()
current = int(year)
run = True
while run:
	current += 1
	if len(set(list(str(current)))) == len(list(str(current))):
		print(current)
		run = False


def ziba(a):
	a = str(a)
	b = 0
	l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for j in range(10):
		for i in range(len(a)):
			if int(a[i]) == j:
				l[j] = l[j] + 1
	for z in range(10):
		if l[z] >= 2:
			b = b + 1
	if b == 0:
		return True
	else:
		return False
a = int(input())
while True:
	a = a + 1
	if ziba(a) == True:
		print(a)
		break


year = int(input())
while 1:
	year += 1
	yl = list(map(int, str(year)))
	a = yl[0]
	b = yl[1]
	c = yl[2]
	d = yl[3]
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(year)


a = int(input())
y = True
while y:
	a += 1
	if len(set(str(a))) == 4:
		print(a)
		y = False


y = int(input())
y2 = y
while True:
	y2 = y2 + 1
	y2str = str(y2)
	if len(y2str) == len(set(y2str)):
		print(y2)
		break


n = int(input())
for i in range(n + 1, 10000):
	s = str(i)
	a = set()
	j = i
	while i > 0:
		r = i % 10
		a.add(r)
		i = i // 10
	if len(a) == 4:
		print(j)
		break


def uniqueCharacters(str):
	for i in range(len(str)):
		for j in range(i + 1, len(str)):
			if str[i] == str[j]:
				return False
	return True
n = input()
n = str(int(n) + 1)
while 1:
	if uniqueCharacters(n):
		print(n)
		break
	else:
		n = str(int(n) + 1)


n = input()
y = int(n) + 1
while len(set(str(y))) != 4:
	y = y + 1
print(y)


i = int(input())
s = 0
while s < 1:
	i = i + 1
	p = str(i)
	if len(p) == len(set(p)):
		s = s + 1
print(i)


testYear = int(input())
while True:
	testYear += 1
	testSet = set(str(testYear))
	if len(testSet) == 4:
		break
print(testYear)


year = input()
i = int(year)
while True:
	i = i + 1
	Str = str(i)
	s = set(Str)
	if len(s) == 4:
		break
print(i)


m = int(input())
while True:
	m = m + 1
	M = '%d' % m
	M = list(M)
	n = len(M)
	if len(list(set(M))) == n:
		print(m)
		break
	else:
		pass


s = int(input())
s += 1
while len(str(s)) != len(list(set(str(s)))):
	s += 1
print(s)


year = int(input())

def all_digit_is_different(x):
	s = str(x)
	return len(set(s)) == 4
current_year = year + 1
while not all_digit_is_different(current_year):
	current_year += 1
print(current_year)


a = int(input())
z1 = 0
for i in range(a + 1, a + 1000):
	b = []
	c = i
	while c != 0:
		r = c % 10
		b.append(r)
		c = c // 10
	b1 = b[::-1]
	b.sort()
	z = 0
	for j in range(len(b) - 1):
		if b[j] != b[j + 1]:
			z = z + 1
		else:
			break
	if z == len(b) - 1:
		print(*b1, sep='')
		z1 = z1 + 1
		break


s = int(input())
t = s + 1
ans = 0
while ans == 0:
	d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	tt = t
	while tt > 0:
		d[tt % 10] += 1
		tt //= 10
	cnt = 0
	for i in range(0, 10):
		if d[i] != 0:
			cnt += 1
	if cnt == 4:
		ans = 1
	t += 1
print(t - 1)


def isdistinct(year):
	year = str(year)
	s = ''
	for i in year:
		if i not in s:
			s += i
	return len(s) == len(year)
n = int(input()) + 1
while True:
	if isdistinct(n):
		print(n)
		break
	else:
		n += 1


n = int(input())
b = [0, 0, 0, 0]
prt = 0
while True:
	n += 1
	for i in range(4):
		b[i] = str(n)[i]
	t = 1
	b.sort()
	for i in range(3):
		t *= int(b[i]) - int(b[i + 1])
	if t == 0:
		pass
	else:
		prt = n
		break
print(n)


x = str(int(input()) + 1)
i = 0
while i < 4:
	c = 0
	j = i + 1
	while j < 4:
		if x[i] == x[j]:
			x = str(int(x) + 1)
			i = 0
			c += 1
		else:
			j += 1
	if c == 0:
		i += 1
print(x)


n = int(input())
for i in range(n + 1, 1000000000000000000000000000000000000000000000000000000000):
	a = i % 10
	b = i % 100 // 10
	c = i % 1000 // 100
	d = i % 10000 // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(i)
		break


year = int(input())
for i in range(year + 1, 10000):
	digits = []
	y = i
	while i > 0:
		r = i % 10
		if r not in digits:
			digits.append(r)
		else:
			break
		i = int(i / 10)
	if len(digits) == 4:
		print(y)
		break


init_year = int(input())
for year in range(init_year + 1, 9013):
	if len(set(str(year))) == len(list(str(year))):
		print(year)
		break


dig = [0, 0, 0, 0]
y = int(input())
while True:
	dig = [0, 0, 0, 0]
	y += 1
	z = y
	for i in range(4):
		dig[i] = z % 10
		z = z // 10
	stat = 1
	for i in range(3):
		for j in range(i + 1, 4):
			if dig[i] == dig[j]:
				stat = 0
				break
		if stat == 0:
			break
	if stat == 0:
		continue
	else:
		print(y)
		break


__author__ = 'widoc'
year = int(input())
for i in range(year + 1, 9100):
	year_str = str(i)
	year_dig_set = set(year_str)
	if len(year_dig_set) == 4:
		print(i)
		break


from collections import Counter
y = int(input())
done = False

def distinct(x):
	x = Counter(list(str(x)))
	c = {}
	for (key, value) in x.items():
		c[key] = value
		if value > 1:
			return False
	return True
while done == False:
	y += 1
	done = distinct(y)
print(y)


Year = int(input())
for i in range(Year + 1, 10000):
	s = []
	s.append(str(i)[0])
	s.append(str(i)[1])
	s.append(str(i)[2])
	s.append(str(i)[3])
	if len(set(s)) == 4:
		print(i)
		break


n = input()
n = int(n)
ls = []
for x in range(1000, 9013):
	x = str(x)
	year_set = set(x)
	year_list = list(x)
	if len(year_set) == len(year_list):
		ls.append(x)
m = 0
if n in ls:
	print(n)
else:
	for t in ls:
		t = int(t)
		if t > n:
			m = t
			break
	print(m)


def main():
	a = int(input())
	x = a + 1
	while True:
		b = str(x)
		if b[0] != b[1] and b[1] != b[2] and (b[2] != b[3]) and (b[0] != b[2]) and (b[1] != b[3]) and (b[0] != b[3]):
			print(int(b))
			break
		else:
			x += 1
main()


n = int(input())
k = 1
while True:
	n = n + k
	s = str(n)
	li = list(s)
	if li[0] != li[1] and li[0] != li[2] and (li[0] != li[3]) and (li[1] != li[2]) and (li[1] != li[3]) and (li[2] != li[3]):
		st = ''.join(li)
		print(int(st))
		break
	else:
		pass


y = int(input())
y2 = y
s = set()
it = 0
for i in range(y):
	s.clear()
	y = y + 1
	m = list(str(y))
	for item in m:
		s.add(item)
	if len(s) == 4:
		it = i
		break
print(it + y2 + 1)


year = int(input())
nxtYear = year
digits = {0}
while len(digits) != 4:
	nxtYear += 1
	digits = set(str(nxtYear))
print(nxtYear)


a = int(input())
a = a + 1
z = True

def check(a):
	count = 0
	s = str(a)
	b = list(s)
	c = len(b)
	for i in range(c):
		j = i + 1
		for j in range(j, c):
			if b[i] == b[j]:
				count = count + 1
	if count == 0:
		z = False
	else:
		z = True
	return z
while check(a):
	a = a + 1
print(a)


def by(x):
	lx = list(str(x))
	sx = set(str(x))
	if len(lx) == len(sx):
		return 1

def nby(x):
	t = x + 1
	while by(t) != 1:
		t += 1
		continue
	return t
y = int(input())
print(nby(y))


year = int(input().strip())
year += 1
while 1:
	if len(set(str(year))) == 4:
		print(year)
		break
	year += 1


x = int(input())
test = False
y = x + 1
s = ''
chck = 0

def check(string):
	for i in range(1, 4):
		if string[0] == string[i]:
			return False
	for i in range(2, 4):
		if string[1] == string[i]:
			return False
	if string[2] == string[3]:
		return False
	return True
while test == False:
	s = str(y)
	result = check(s)
	if result == True:
		print(y)
		test = True
	y = y + 1


n = int(input())
m = []
c = 0
while c == 0:
	m = []
	n += 1
	f = list(str(n))
	for i in range(len(f)):
		if f[i] not in m:
			m.append(f[i])
	if len(m) == 4:
		c = 1
print(int(''.join(m)))


def appropriate(y):
	for i in range(3):
		for j in range(i + 1, 4):
			if y[i] == y[j]:
				return False
	return True

def inc(y):
	for i in range(3, -1, -1):
		if y[i] < 9:
			y[i] += 1
			return y
		else:
			y[i] = 0
y = [int(c) for c in input()]
inc(y)
while not appropriate(y):
	inc(y)
for c in y:
	print(c, end='')


a = int(input())
b = a
while True:
	b += 1
	c = list(str(b))
	if c[0] != c[1]:
		if c[0] != c[2]:
			if c[0] != c[3]:
				if c[1] != c[2]:
					if c[1] != c[3]:
						if c[2] != c[3]:
							break
for i in range(0, 4):
	print(c[i], end='')


def distinct_digits(n):
	seen = set()
	while n:
		digit = n % 10
		if digit in seen:
			return False
		seen.add(digit)
		n //= 10
	return True
year = int(input())
for n in range(year + 1, 10000):
	if distinct_digits(n):
		print(n)
		break


year = int(input())

def year_find(x):
	a = x % 10
	b = x // 10 % 10
	c = x // 100 % 10
	d = x // 1000 % 10
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		return 1
	else:
		return 0
for i in range(year + 1, 9999):
	x = year_find(i)
	if x == 1:
		print(i)
		break


x = int(input()) + 1
y = str(x)
while len(set(y)) != len(y):
	x += 1
	y = str(x)
else:
	print(x)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	i = n + 1
	while 1:
		s = str(i)
		c = collections.Counter(s)
		if len(s) == len(c):
			return i
		i += 1
	return -1
print(main())


def check(year):
	l = len(year)
	for i in range(l - 1):
		for j in range(i + 1, l):
			if year[i] == year[j]:
				return True
	return False
y = int(input())
y += 1
y_as_str = str(y)
while check(y_as_str):
	y += 1
	y_as_str = str(y)
print(y_as_str)


def is_ans(n: int):
	numbers = set()
	for i in str(n):
		if not i in numbers:
			numbers.add(i)
		else:
			return False
	return True
num = int(input())
num += 1
while not is_ans(num):
	num += 1
print(num)


a = int(input())
a += 1
a = str(a)
a = list(a)
x = 0
l = ''.join(a)
l = int(l)
while a[0] == a[1] or a[1] == a[2] or a[2] == a[3] or (a[3] == a[0]) or (a[0] == a[2]) or (a[1] == a[3]) or (a[2] == a[0]) or (a[3] == a[1]) or (a[0] == a[3]) or (a[1] == a[0]) or (a[2] == a[1]) or (a[3] == a[2]):
	l = ''.join(a)
	l = int(l)
	l += 1
	l = str(l)
	x += 1
	a = list(l)
print(l)


def nodup(n):
	d = {}
	while n:
		digit = n % 10
		if d.get(digit, False):
			return False
		d[digit] = True
		n //= 10
	return True
n = int(input()) + 1
while True:
	if nodup(n):
		print(n)
		break
	n += 1


def distinct(y):
	for i in y:
		if len(set(y)) == len(y):
			return 1
		else:
			return 0
y = int(input())
k = y + 1
while k >= y:
	l = distinct(str(k))
	if l == 1:
		print(str(k))
		break
	elif l == 0:
		k += 1


n = int(input())
n += 1
while len(set(map(int, str(n)))) != 4:
	n += 1
else:
	print(n)


def isBeautiful(num):
	temp = []
	while num >= 1:
		temp.append(num % 10)
		num = num // 10
	if len(temp) == len(set(temp)):
		return True
	return False
year = int(input())
year += 1
while isBeautiful(year) == False:
	year += 1
print(year)


x = int(input())
z = x + 1
y = z + 102
while z < y:
	a = []
	for i in list(str(z)):
		a.append(list(str(z)).count(i))
	if sum(a) == 4:
		print(z)
		break
	else:
		z += 1


def beautiful(yr):
	for i in yr:
		if yr.count(i) < 2:
			continue
		else:
			return False
	return True
year = int(input())
while True:
	if beautiful(str(year + 1)):
		year += 1
		break
	else:
		year += 1
print(year)


N = int(input()) + 1
N = str(N)
while N[0] == N[1] or N[1] == N[2] or N[2] == N[3] or (N[0] == N[2]) or (N[0] == N[3]) or (N[1] == N[3]):
	N = int(N) + 1
	N = str(N)
print(N)


n = int(input())
while True:
	x = n + 1
	s = str(x)
	l = []
	for i in s:
		l.append(i)
	l.sort()
	count = 0
	for j in range(len(l)):
		if j == len(l) - 1:
			break
		if l[j] != l[j + 1]:
			count += 1
	if count + 1 == len(l):
		print(x)
		break
	else:
		n = n + 1


x = int(input())
c = [1] * len(str(x))
d = []
x = str(int(x) + 1)
while True:
	for i in str(x):
		d.append(str(x).count(i))
	x = str(int(x) + 1)
	if c == d:
		break
	d = []
print(int(x) - 1)


y = int(input())
while True:
	lis = []
	y += 1
	y = str(y)
	for i in range(len(y)):
		b = 0
		b = y.count(y[i])
		if b == 1:
			lis.append(y[i])
	if len(lis) == 4:
		print(y)
		break
	else:
		b = 0
		y = int(y)


n = int(input())
l = 0
while l == 0:
	n = n + 1
	if len(set(str(n))) == len(str(n)):
		print(n)
		l = 1
		break


y = int(input())
y_inf = y + 1
while y_inf > y:
	y_inf_list = [i for i in str(y_inf)]
	y_inf_set = set(y_inf_list)
	if len(y_inf_list) == len(y_inf_set):
		break
	y_inf = y_inf + 1
print(y_inf)


y = int(input())
while 1:
	y = y + 1
	y = str(y)
	l = [int(x) for x in y]
	if len(l) == len(list(set(l))):
		print(int(''.join((str(i) for i in l))))
		break
	else:
		y = int(''.join((str(i) for i in l)))


def distinct(num):
	for digit in str(num):
		if str(num).count(digit) > 1:
			return False
	return True
number = int(input()) + 1
while True:
	if distinct(number):
		break
	else:
		number = number + 1
print(number)


from collections import Counter

def dis(n):
	c = Counter(n)
	for v in c.values():
		if v > 1:
			return False
	return True
ip = int(input())
res = ip + 1
n = list(str(res))
while not dis(n):
	res += 1
	n = list(str(res))
print(res)


import bisect
li = []
for i in range(1000, 9999):
	if len(set(str(i))) == 4:
		li.append(i)
n = int(input())
print(li[bisect.bisect_right(li, n)])


from collections import Counter
a = str(int(input()) + 1)
c1 = len(Counter(a))
a = int(a)
while c1 != 4:
	a += 1
	a = str(a)
	c1 = len(Counter(a))
	a = int(a)
print(a)


y = str(int(input()) + 1)
run = True
while run:
	lst = []
	for i in y:
		if i not in lst:
			lst.append(i)
	if len(lst) == 4:
		run = False
		y = ''.join(lst)
	else:
		y = str(int(y) + 1)
print(y)


n = int(input())
while n >= 1000:
	e = str(n + 1)
	s = set(e)
	if len(s) == len(e):
		print(n + 1)
		break
	n = n + 1


from collections import OrderedDict
n = input()
sum = int(n)
for i in range(1000):
	sum = sum + 1
	w = ''.join(OrderedDict.fromkeys(str(sum)).keys())
	if len(w) == 4:
		print(sum)
		break
	else:
		continue


def beautiful_year(n):
	while True:
		count = 0
		n = n + 1
		temp = str(n)
		for a in temp:
			for b in temp:
				if a == b:
					count = count + 1
		if count == 4:
			return n
		else:
			count = 0
n = int(input())
print(beautiful_year(n))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def check(n):
	s = str(n)
	if len(set(s)) == len(s):
		return True
	else:
		return False
n = get_int() + 1
flag = True
while flag:
	if check(n):
		flag = False
	else:
		n += 1
print(n)


year_str = input()
year_num = int(year_str)
for i in range(year_num + 1, 10000):
	year_list = [int(j) for j in list(str(i))]
	if len(set(year_list)) == 4:
		print(i)
		break


a = int(input())
check = False
found = False
for i in range(1000):
	if found:
		break
	a += 1
	s = str(a)
	for x in range(len(s)):
		for z in range(x + 1, len(s)):
			if s[x] == s[z]:
				check = True
				break
			elif z == len(s) - 1 and x == len(s) - 2:
				print(a)
				found = True
		if check:
			check = False
			break


def getNextDistinct(y):
	y = str(int(y) + 1)
	mylist = list(y)
	mydict = {}
	for x in mylist:
		if x not in mydict:
			mydict[x] = 1
		else:
			mylist = []
			getNextDistinct(y)
			break
	for i in mylist:
		print(i, end='')
y = input()
getNextDistinct(y)


n = int(input())
for i in range(n + 1, 9000000):
	lst = [int(x) for x in str(i)]
	if len(set(lst)) == len(lst):
		print(i)
		break


y = eval(input())
c = y + 1
flag = False
while c < 1000000 and flag == False:
	b = str(c)
	if b[0] != b[1] and b[0] != b[2] and (b[0] != b[3]) and (b[1] != b[2]) and (b[1] != b[3]) and (b[2] != b[3]):
		flag = True
	else:
		c += 1
if flag:
	print(c)


y = int(input())
y += 1
while True:
	ma = {}
	sy = str(y)
	dupli = False
	for c in sy:
		if c in ma:
			dupli = True
			break
		ma[c] = 1
	if not dupli:
		print(y)
		break
	y += 1


def get_beautiful_year(year):
	current_year = year + 1
	while 1:
		if distinct_digits(current_year):
			return current_year
		current_year += 1

def distinct_digits(num):
	numbers = set()
	while 1:
		remainder = num % 10
		if remainder in numbers:
			return False
		numbers.add(remainder)
		num = num // 10
		if num < 1:
			return True
print(get_beautiful_year(int(input(''))))


a = int(input())
b = str(a + 1)
while True:
	c = 0
	for i in b:
		if b.count(i) == 1:
			c = c + 1
		else:
			continue
	if c == len(b):
		break
	else:
		b = str(int(b) + 1)
print(b)


n = int(input())
n += 1
while 1:
	l = list(map(int, str(n)))
	import collections
	y = collections.Counter(l)
	q = y.values()
	if len(q) == 4:
		print(n)
		break
	n += 1


from sys import stdin, exit
year = int(stdin.readline().rstrip())
year += 1
digits = [0] * 10
while True:
	t = year
	while t > 0:
		digits[t % 10] += 1
		t //= 10
	answer = True
	for i in range(10):
		if digits[i] > 1:
			answer = False
		digits[i] = 0
	if answer:
		print(year)
		exit()
	year += 1


a = int(input())
for i in range(a + 1, 9500):
	if len(set([j for j in str(i)])) == 4:
		print(i)
		break


k = int(input())
while True:
	k += 1
	n = k
	n1 = n // 1000
	r1 = n % 1000
	n2 = r1 // 100
	r2 = r1 % 100
	n3 = r2 // 10
	n4 = r2 % 10
	if n1 != n2 and n1 != n3 and (n1 != n4) and (n2 != n3) and (n2 != n4) and (n3 != n4):
		print(n)
		break


oy = int(input())
ny = str(oy + 1)
while ny.count(ny[0]) > 1 or ny.count(ny[1]) > 1 or ny.count(ny[2]) > 1 or (ny.count(ny[3]) > 1):
	ny = str(int(ny) + 1)
print(ny)


num = int(input())
next_year = num + 1
a = sorted(list(str(next_year)))
b = sorted(set(list(str(next_year))))
while len(a) != len(b):
	next_year += 1
	a = sorted(list(str(next_year)))
	b = sorted(set(list(str(next_year))))
print(next_year)


def is_distinct_digit(n):
	ns = list(str(n))
	nss = set(ns)
	return len(nss) == len(ns)
year = int(input()) + 1
while not is_distinct_digit(year):
	year += 1
print(year)


def f(god):
	c1 = god // 1000
	c2 = god // 100 % 10
	c3 = god // 10 % 10
	c4 = god % 10
	if c1 == c2 or c1 == c3 or c1 == c4 or (c2 == c3) or (c2 == c4) or (c3 == c4):
		return False
	if c1 != c2 != c3 != c4:
		return True
g = int(input())
g += 1
while not f(g):
	g += 1
print(g)


s = int(input()) + 1
s = str(s)
for i in range(1000):
	s0 = int(s[0])
	s1 = int(s[1])
	s2 = int(s[2])
	s3 = int(s[3])
	if len({s0, s1, s2, s3}) == 4:
		print(s)
		break
	else:
		s = int(s) + 1
		s = str(s)


current = int(input())
next = current + 1
while 1:
	next_str = str(next)
	next_set = set(next_str)
	if len(next_set) == 4:
		print(next)
		break
	next += 1


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

def i():
	return sys.stdin.readline().strip()

def ii():
	return int(sys.stdin.readline())

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	a = ii()
	while True:
		a += 1
		b = list(str(a))
		c = []
		[c.append(x) for x in b if x not in c]
		if len(b) == len(c):
			print(a)
			return False
solve()


def abc():
	t = int(input())
	t = t + 1
	flag = 0
	while t <= 90012:
		st = list(str(t))
		i = 0
		count = 0
		while i < 4:
			a = st.pop()
			if a in st:
				break
			else:
				count = count + 1
			if count == 4:
				print(t)
				flag = 1
				break
			i = i + 1
		t = t + 1
		if flag == 1:
			break
	return
abc()


n = int(input())
z = []
w = True
for i in range(n + 1, 100000):
	z = []
	for j in str(i):
		if j not in z:
			z.append(j)
		else:
			break
		if len(z) == len(str(i)):
			print(i)
			w = False
			break
	if not w:
		break


year = input()
d1 = int(year[0])
d2 = int(year[1])
d3 = int(year[2])
d4 = int(year[3])
d4 = int(d4 + 1)
if int(d4) == int(10):
	d4 = int(0)
	d3 = int(d3 + 1)
if int(d3) == int(10):
	d3 = 0
	d2 = int(d2 + 1)
if int(d2) == int(10):
	d2 = 0
	d1 = int(d1 + 1)
while d1 == d2 or d1 == d3 or d1 == d4 or (d2 == d3) or (d2 == d4) or (d3 == d4):
	d4 = d4 + 1
	if int(d4) == int(10):
		d4 = int(0)
		d3 = int(d3 + 1)
	if int(d3) == int(10):
		d3 = 0
		d2 = int(d2 + 1)
	if int(d2) == int(10):
		d2 = 0
		d1 = int(d1 + 1)
print(str(d1) + str(d2) + str(d3) + str(d4))


def check(p):
	if len(set(p)) == 4:
		return True
	else:
		return False
n = int(input())
T = n + 1
while True:
	if check(str(T)) == True:
		print(T)
		break
	else:
		T += 1


n = int(input())
i = n + 1
while True:
	s = set()
	for ch in str(i):
		s.add(ch)
	if len(s) == len(str(i)):
		print(i)
		break
	i = i + 1


x = int(input())
for i in range(x + 1, 10000):
	if len(str(i)) == len(set(str(i))):
		print(i)
		break
	else:
		continue


y = int(input())
while True:
	y += 1
	a = y % 10
	b = y % 100 // 10
	c = y % 1000 // 100
	d = y % 10000 // 1000
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		print(y)
		break
	else:
		continue


year = int(input())
startYear = year + 1

def areDigitsDistinct(number):
	return len(str(number)) == len(set(str(number)))
while areDigitsDistinct(startYear) != True:
	startYear = startYear + 1
print(startYear)


n = input()
temp = int(n)
while True:
	lst = []
	for i in n:
		lst.append(i)
	if len(set(lst)) == len(n) and temp < int(n):
		print(n)
		exit()
	else:
		n = int(n) + 1
		n = str(n)


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	n += 1
	while True:
		if len(str(n)) == len(set(str(n))):
			break
		else:
			n += 1
	stdout.write(str(n))
main()


y = int(input())
while True:
	y += 1
	(num, q1, count) = (y, [], 0)
	while num != 0:
		q = num % 10
		num //= 10
		if q not in q1:
			q1.append(q)
			count += 1
		else:
			break
	if count == 4:
		print(y)
		break


def isBeautiful(num):
	temp = []
	while num >= 1:
		temp.append(num % 10)
		num = num // 10
	if len(temp) == len(set(temp)):
		return True
	return False
year = int(input())
flag = False
i = 0
breakFlag = False
while True:
	if isBeautiful(year // 10):
		x = year % 10
		year = year // 10
		year = year * 10
		if flag:
			for i in range(10):
				year += i
				if isBeautiful(year):
					breakFlag = True
					break
				year -= i
		if breakFlag:
			break
		else:
			year += x + 1
			if isBeautiful(year):
				break
			continue
	else:
		flag = True
		year += 10
print(year)


import sys
m = sys.stdin.readline()
alist = m.split()
mlist = []
for i in range(10001):
	if len(list(set(str(i)))) >= 4 and i > int(m):
		mlist.append(i)
print(str(mlist[0]))


s = int(input())
while True:
	s = s + 1
	s2 = str(s)
	d = {}
	a = 0
	for i in range(0, len(s2)):
		try:
			d[s2[i]] += 1
			if d[s2[i]] > 1:
				a = 1
				break
		except:
			d[s2[i]] = 1
	if a == 0:
		break
print(s)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
ans = N + 1
while True:
	s = str(ans)
	if len(s) == len(set(s)):
		print(ans)
		exit(0)
	ans += 1


def spl(ch):
	return [c for c in ch]
c = input()
lis = spl(c)
for i in range(int(c) + 1, 90000):
	if len(spl(str(i))) == len(set(spl(str(i)))):
		print(i)
		break


n = input()
m = int(n) + 1
s = 'aa' + str(m) + 'aa'
ans = 0
while ans == 0:
	z = 0
	for i in range(2, 6):
		if s[i] in s[:i] or s[i] in s[i + 1:]:
			s = 'aa' + str(int(s[2:-2]) + 1) + 'aa'
			break
		else:
			z += 1
		if z == 4:
			ans = s[2:-2]
			break
print(ans)


y = int(input())
for i in range(y + 1, 9013):
	l = [i // 1000 % 10, i // 100 % 10, i // 10 % 10, i % 10]
	for k in range(4):
		z = 0
		for j in range(k + 1, 4):
			if l[k] == l[j]:
				z = 1
				break
		if z == 1:
			break
	if z == 0:
		print(i)
		break


def check(n):
	a = set()
	while n > 0:
		a.add(n % 10)
		n //= 10
	return len(a) == 4
n = int(input())
for i in range(n + 1, 10000):
	if check(i):
		print(i)
		break


def check(t):
	a = t % 10
	b = t // 10 % 10
	c = t // 100 % 10
	d = t // 1000 % 10
	if a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
		return False
	else:
		return True
n = int(input())
n += 1
while True:
	if check(n):
		print(n)
		exit()
	n += 1


def isDistinct(n):
	return len(set(n)) == len(n)
n = int(input()) + 1
while not isDistinct(str(n)):
	n += 1
print(n)


num = int(input())

def unique_year(n):
	unique = []
	for i in str(n):
		if i not in unique:
			unique.append(i)
	if len(unique) == 4:
		return True
years = []
for i in range(1000, 10000):
	if unique_year(i):
		years.append(i)
if num in years:
	x = years.index(num)
	print(years[x + 1])
else:
	for i in years:
		if i > num:
			print(i)
			break


year = int(input())
output = 0
while output == 0:
	distinct = True
	year += 1
	year = str(year)
	for i in range(3):
		if year[i] in year[i + 1:]:
			distinct = False
			break
	if distinct:
		output = 1
	else:
		year = int(year)
print(year)


y = int(input()) + 1
t = 0
while t == 0:
	k = 0
	for i in range(10):
		if str(y).count(str(i)) > 1:
			y += 1
			k = 1
			break
	if k == 0:
		t = 1
print(y)


def isdistincts(n):
	if len(set(str(n))) == len(str(n)):
		return True
	return False
n = int(input())
i = n + 1
while 1:
	if isdistincts(i):
		print(i)
		break
	else:
		i += 1


print(next((a for a in range(int(input()) + 1, 12345) if len(set(str(a))) == len(str(a)))))


n = int(input())
n = n + 1
n = str(n)
i = 1
while i:
	temp = list(set(list(n)))
	if len(temp) == 4:
		i = 0
	else:
		n = int(n)
		n = n + 1
		n = str(n)
print(n)


def m(a):
	v = []
	while a != 0:
		v.append(a % 10)
		a = a // 10
	return v
a = int(input()) + 1
for i in range(101):
	b = set(m(a))
	if len(b) == 4:
		print(a)
		break
	else:
		a += 1


def add_one_to_the_index(list_of_number, index):
	if list_of_number[index] == 9:
		list_of_number[index] = 0
		add_one_to_the_index(list_of_number, index - 1)
	else:
		list_of_number[index] = list_of_number[index] + 1
		return

def make_all_others_zero(list_of_number, index):
	global length
	for i in range(index + 1, length):
		list_of_number[i] = 0

def find_repeating_index(list_of_number):
	global length
	for i in range(0, length - 1):
		if list_of_number[i] in list_of_number[i + 1:]:
			return (i, list_of_number[i + 1:].index(list_of_number[i]) + i + 1)
	return (-1, -1)
length = 4
list_of_number = list(map(int, input()))
add_one_to_the_index(list_of_number, length - 1)
while True:
	(index1, index2) = find_repeating_index(list_of_number)
	if index1 == index2 == -1:
		for i in range(length):
			print(list_of_number[i], end='')
		break
	else:
		add_one_to_the_index(list_of_number, index2)
		make_all_others_zero(list_of_number, index2)


y = int(input())
x = y + 1
while True:
	s = str(x)
	f = 1
	for i in range(len(s)):
		if s[i] in s[i + 1:]:
			f = 0
			break
	if f:
		print(s)
		break
	x += 1


y = 1 + int(input())
while True:
	s1 = set()
	for it in str(y):
		s1.add(it)
	if len(s1) == 4:
		break
	y += 1
print(y)


def div(n):
	t = n
	li = []
	while n != 0:
		li.append(n % 10)
		n //= 10
	s = set(li)
	if len(li) == len(s):
		return t
	else:
		return div(t + 1)
n = int(input())
print(div(n + 1))


year = int(input())
results = 'no'
while results != 'yes':
	digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	year += 1
	string = str(year)
	digit = 0
	while digit < len(string):
		try:
			digits.remove(string[digit])
		except ValueError:
			break
		digit += 1
	if digit == len(string):
		results = 'yes'
print(year)


a = input()
b = int(a)
while True:
	b += 1
	c = str(b)
	list1 = [int(i) for i in c]
	if list1.count(list1[0]) == 1 and list1.count(list1[1]) == 1 and (list1.count(list1[2]) == 1):
		break
print(b)


year = input()
n = int(year)
n1 = 9000
list1 = list(year)
for i in range(n1):
	year1 = str(n + 1 + i)
	year2 = list(year1)
	n2 = 0
	n3 = len(year2)
	for x in year2:
		a = year2.count(x)
		if a == 1:
			n2 += 1
	if n2 == n3:
		print(year1)
		break


n = int(input())
n += 1
l = [i for i in str(n)]
while len(l) != len(set(l)):
	n = int(n) + 1
	l = [i for i in str(n)]
print(int(n))


def krasota(ch):
	a = set()
	k = 0
	while ch != 0:
		a.add(ch % 10)
		ch = ch // 10
		k = k + 1
	if len(a) == k:
		return 1
	else:
		return 0
n = int(input())
while True:
	n = n + 1
	if krasota(n) == 1:
		print(n)
		break


n = int(input()) + 1
while 1:
	n = str(n)
	if len(n) == len(set(n)):
		print(n)
		exit()
	n = int(n) + 1


def checa_digitos_distintos(n):
	n = int(n)
	global digitos
	while n > 0:
		ult_digito = n % 10
		if digitos[ult_digito] == 1:
			return False
		else:
			digitos[ult_digito] = 1
		n = int(n / 10)
	return True
y = int(input()) + 1
digitos = [0] * 10
aux = checa_digitos_distintos(y)
while aux == False:
	y = y + 1
	digitos = [0] * 10
	aux = checa_digitos_distintos(y)
print(y)


n = int(input())
while True:
	n += 1
	n = str(n)
	lst = []
	for i in range(len(n)):
		lst.append(n.count(n[i]))
	if lst.count(1) == len(lst):
		break
	else:
		n = int(n)
print(n)


year = str(int(input()) + 1)
flag = True
while flag:
	if year.count(year[0]) > 1 or year.count(year[1]) > 1 or year.count(year[2]) > 1 or (year.count(year[3]) > 1):
		year = str(int(year) + 1)
	else:
		print(year)
		flag = False


b = input()
s = int(b) + 1
while len(set([str(s)[0], str(s)[1], str(s)[2], str(s)[3]])) != 4:
	s += 1
print(s)


i = int(input())

def beautifulYear(i):
	charList = []
	for char in str(i):
		if char in charList:
			return beautifulYear(i + 1)
		charList.append(char)
	return i
print(beautifulYear(i + 1))


def distinct_digits(year):
	(rem, d0) = divmod(year, 10)
	(rem, d1) = divmod(rem, 10)
	(rem, d2) = divmod(rem, 10)
	digits = {d0, d1, d2, rem}
	if len(digits) == 4:
		return True
	return False
year = int(input()) + 1
while not distinct_digits(year):
	year += 1
print(year)


y = int(input())
a = True
while a:
	y += 1
	s = str(y)
	if s[0] != s[1] != s[2] != s[3] != s[1] and s[3] != s[0] != s[2]:
		a = False
print(y)


def isDistinct(num):
	list1 = [0] * 10
	for i in range(0, len(num)):
		if list1[int(num[i]) - 1] == 0:
			list1[int(num[i]) - 1] += 1
		else:
			return 0
			break
	return 1
num1 = input()
x = int(num1) + 1
list1 = []
found = 0
while found != 1:
	if isDistinct(list(str(x))) == 0:
		x += 1
	else:
		print(x)
		found = 1


def ok(a):
	s = str(a)
	b = ''
	r = True
	for i in s:
		if b.find(i) == -1:
			b += i
		else:
			r = False
	return r
y = int(input())
i = y + 1
while not ok(i):
	i += 1
print(i)


n = int(input())
m = 0
while True:
	m = 0
	v = n + 1
	s = str(v)
	for i in s:
		if s.count(i) > 1:
			break
		else:
			m = m + 1
	n = v
	if m == len(s):
		break
print(v)


y = int(input())
status = False
while not status:
	y += 1
	if len(str(y)) == len(set(str(y))):
		status = True
print(y)


y = int(input()) + 1
for i in range(200):
	yr = [int(x) for x in list(str(y))]
	temp = []
	for j in range(4):
		if yr[j] in temp:
			break
		else:
			temp.append(yr[j])
	if len(temp) == 4:
		print(y)
		break
	else:
		y += 1


def year(number):
	while True:
		if len(number) == len(set(number)):
			return int(number)
		else:
			number = str(int(number) + 1)
number = int(input())
print(year(str(number + 1)))


def isUnique(strYear):
	numbers = '0123456789'
	uniques = 0
	for num in numbers:
		if strYear.__contains__(num):
			uniques += 1
	return uniques == 4
year = int(input())
for y in range(year + 1, 10000):
	if isUnique(str(y)):
		print(y)
		break


def cheq(u):
	Hash = [0] * 10
	while u:
		Hash[u % 10] += 1
		u //= 10
	for x in Hash:
		if x > 1:
			return False
	return True
n = int(input())
while True:
	n += 1
	if cheq(n):
		print(n)
		break


def distinct_year(year):
	res = True
	for i in year:
		if year.count(i) > 1:
			res = False
			break
	return res
y = int(input())
y += 1
while not distinct_year(str(y)):
	y += 1
print(y)


def beautiful(y):
	L = []
	string = str(y)
	for i in string:
		L.append(i)
	for j in L:
		if L.count(j) != 1:
			return False
			break
	return True
n = int(input())
m = n
if beautiful(n):
	n += 1
	ans = n
while not beautiful(n) and m <= n:
	n += 1
	ans = n
print(ans)


def has_distinct_digits(x):
	s = str(x)
	for c in s:
		if s.count(c) > 1:
			return False
	else:
		return True
y = int(input())
while True:
	y += 1
	if has_distinct_digits(y):
		print(y)
		break


s = input()
s = int(s)
s = s + 1
x = 1
while x == 1:
	p = len(set(str(s)))
	if len(str(s)) == p:
		print(s)
		x = 2
	else:
		s = int(s) + 1


n = int(input())

def isdistict(num):
	count = 0
	for i in str(num):
		for j in str(num):
			if i == j:
				count += 1
	if count == len(str(num)):
		return True
	else:
		return False
for i in range(n + 1, 9013):
	if isdistict(i) is True:
		print(i)
		exit()
	else:
		continue


def check(n):
	l = list(str(n))
	if len(l) == len(set(l)):
		return 1
	return 0
n = input()
t = int(n)
while True:
	t = t + 1
	if check(t) == 1:
		print(t)
		break


s = str(int(input()) + 1)
flag = 0
while flag != 1:
	r = []
	for i in s:
		if i not in r:
			r.append(i)
	if len(r) == 4:
		flag = 1
		break
	else:
		s = str(int(s) + 1)
print(int(s))


def distinct(num):
	zero = num % 10
	ten = int(num / 10) % 10
	hund = int(num / 100) % 10
	thou = int(num / 1000) % 10
	if zero == hund or hund == thou or thou == zero or (zero == ten) or (ten == hund) or (ten == thou) or (zero == thou):
		return 0
	else:
		return 1
yr = int(input())
while True:
	yr += 1
	if distinct(yr) == 1:
		print(yr)
		break


def isdifferent(word):
	lis = []
	for el in word:
		if el in lis:
			return False
		else:
			lis.append(el)
	return True

def main():
	from sys import stdout
	year = str(int(input()) + 1)
	while not isdifferent(year):
		year = str(int(year) + 1)
	print(year)
main()


n = int(input()) + 1
while n != 0:
	b = str(n)
	y = set(b)
	if len(b) == len(y):
		print(n)
		break
	n = n + 1


def isDistinct(year):
	l = [0] * 10
	while year > 0:
		index = year % 10
		l[index] += 1
		if l[index] == 2:
			return False
		year //= 10
	return True
year = int(input())
flagi = True
while flagi:
	year += 1
	if isDistinct(year):
		flagi = False
print(year)


n = int(input()) + 1

def diffDigits(year):
	b = str(year)
	a = set(b)
	if len(a) == len(b):
		return False
	else:
		return True
while diffDigits(n):
	n += 1
print(n)


n = int(input())
for i in range(n + 1, 10001):
	vis = [0] * 10
	nu = 0
	t = i
	while i:
		if vis[i % 10]:
			nu = 1
			break
		vis[i % 10] = 1
		i = int(i / 10)
	if nu == 0:
		print(t)
		break


def czy_poprawny_rok(rok):
	lista = []
	wynik = rok
	while rok > 0:
		if rok % 10 in lista:
			return False
		lista.append(rok % 10)
		rok = rok // 10
	return True

def piekny_rok(rok):
	wynik = rok + 1
	while not czy_poprawny_rok(wynik):
		wynik += 1
	return wynik
print(piekny_rok(int(input())))


y = int(input())
pd = False
x = y
while pd == False:
	x = x + 1
	s = list(str(x))
	s.sort()
	cx = ''
	pd1 = True
	for c in s:
		if cx == c:
			pd1 = False
			break
		else:
			cx = c
	if pd1 == True:
		pd = True
		break
print(x)


n = int(input()) + 1

def check(s):
	for i in range(0, len(s) - 1):
		if s[i] == s[i + 1]:
			return False
	return True
while True:
	temp = str(n)
	s = sorted(temp)
	if check(s):
		print(n)
		break
	n += 1


n = int(input())
for i in range(n + 1, 90000):
	s = str(i)
	m = {x for x in s}
	if len(m) == 4:
		print(i)
		break


year = input()

def function(check):
	flag = 0
	for x in range(4):
		for y in range(x + 1, 4):
			if check[x] == check[y]:
				flag = 1
	if flag == 0:
		return check
	else:
		return function(str(int(check) + 1))
print(function(str(int(year) + 1)))


digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
y = input()
distinct = False
while distinct == False:
	y = int(y)
	y = y + 1
	digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	y = str(y)
	count = 0
	for i in range(0, len(y)):
		index = int(y[i])
		if digits[index] == 0:
			digits[index] = 1
			count = count + 1
		else:
			break
	if count == len(y):
		distinct = True
print(y)


vss = int(input()) + 1
while len(set(str(vss))) < 4:
	vss += 1
print(vss)


year = int(input())

def check(s):
	for i in range(len(s)):
		for j in range(len(s)):
			if i != j and s[i] == s[j]:
				return False
	return True
while True:
	year += 1
	s = str(year)
	if check(s):
		print(year)
		break


r = int(input()) + 1
while len(str(r)) != len(set(str(r))):
	r += 1
print(r)


current_year = int(input())

def find_year(current_year):
	unique = False
	current_check = current_year + 1
	lst_digits = []
	while unique == False:
		for current_num in str(current_check):
			lst_digits.append(int(current_num))
		if len(lst_digits) == len(set(lst_digits)):
			unique = True
			print(current_check)
		else:
			lst_digits = []
			current_check += 1
find_year(current_year)


def alad(r):
	x = str(r)
	y = list(x)
	s = 0
	for i in range(4):
		if y.count(y[i]) == 1:
			s += 1
	if s == 4:
		return True
n = int(input())
m = n + 1
while alad(m) != True:
	m += 1
print(m)


n = int(input())
count = 0
y = n
while count == 0:
	y = y + 1
	z = str(y)
	if z.count('0') <= 1 and z.count('1') <= 1 and (z.count('2') <= 1) and (z.count('3') <= 1) and (z.count('4') <= 1) and (z.count('5') <= 1) and (z.count('6') <= 1) and (z.count('7') <= 1) and (z.count('8') <= 1) and (z.count('9') <= 1):
		print(y)
		count = 1


num = int(input())
while True:
	num += 1
	s = str(num)
	s = list(s)
	f = 0
	for i in range(4):
		for j in range(i + 1, 4):
			if s[i] == s[j]:
				f = 1
	if not f:
		print(''.join(s))
		break


n = int(input()) + 1
t = 0
while t == 0:
	s = str(n)
	if len(s) == len(set(s)):
		print(s)
		t = 1
	else:
		n += 1


def check(a):
	if len(set(str(a))) < 4:
		return True
	else:
		return False
m = []
n = int(input())
for i in range(100000, n - 1, -1):
	if i > n and check(i) == False:
		m.append(i)
print(min(m))


n = input()
a = int(n)
a += 1
n = str(a)
while True:
	for i in n:
		if n.count(i) > 1:
			a += 1
			break
	else:
		break
	n = str(a)
print(a)


import sys
import itertools
a = int(input())
b = 1
while b == 1:
	c = set()
	a += 1
	d = map(int, str(a))
	for i in range(len(str(a))):
		c.add(next(d))
	if len(c) == 4:
		print(a)
		b = 0


def convert(s):
	str1 = ''
	return str1.join(s)
inp = input()
num = int(inp)
num = num + 1
s = str(num)
st = {s[0], s[1], s[2], s[3]}
while st != 4:
	s = str(num)
	st = {s[0], s[1], s[2], s[3]}
	if len(st) == 4:
		break
	num = num + 1
print(s)


x = int(input())
a = x + 1
while True:
	br = a % 10
	bd = a // 10
	cr = bd % 10
	cd = bd // 10
	dr = cd % 10
	dd = cd // 10
	er = dd % 10
	ed = dd // 10
	if br != cr and br != dr and (br != er) and (cr != dr) and (cr != er) and (dr != er):
		print(a)
		break
	a += 1


def year(y):
	y += 1
	while True:
		c0 = y // 1000
		c1 = y // 100 % 10
		c2 = y % 100 // 10
		c3 = y % 10
		if c0 != c1 and c0 != c2 and (c0 != c3) and (c1 != c2) and (c1 != c3) and (c2 != c3):
			c0 = y // 1000
			c1 = y // 100 % 10
			c2 = y % 100 // 10
			c3 = y % 10
			return y
		y += 1
print(year(int(input())))


import sys
n = input()
for j in range(int(n) + 1, sys.maxsize):
	if len(set(str(j))) == 4:
		print(j)
		break


def f(s):
	d = {}
	k = 0
	for ch in s:
		if ch not in d:
			k += 1
			d.update({ch: 0})
	return len(s) == k
n = int(input())
for i in range(n + 1, 1000000):
	if f(str(i)):
		print(i)
		exit()


def f(n):
	b = n
	i = 0
	a = []
	while n > 0:
		a.append(n % 10)
		n = n // 10
	a.reverse()
	while True:
		if a.count(a[i]) <= 1:
			i = i + 1
			if i == len(a) - 1:
				return b
		else:
			break
	return f(b + 1)
n = int(input())
x = f(n + 1)
print(x)


num = int(input())
for var in range(num + 1, 10000):
	x = str(var)
	if len(x) == len(set(x)):
		print(x)
		break


def has_doubles(n):
	return len(set(str(n))) < len(str(n))
a = input()
a = int(a)
a += 1
while has_doubles(a):
	a = int(a)
	a += 1
print(a)


y = input()
s = int(y)
found = 0
while found == 0:
	s += 1
	y = str(s)
	if y.count(y[0]) == 1 and y.count(y[1]) == 1 and (y.count(y[2]) == 1) and (y.count(y[3]) == 1):
		print(s)
		found = 1
		break


d = int(input())
i = d + 1
while i:
	s = str(i)
	if len(s) == len(list(set(s))):
		print(i)
		break
	else:
		i += 1


year = int(input()) + 1

def f(year):
	for i in range(0, 4):
		if str(year).count(str(year)[i]) > 1:
			return 1
while f(year) == 1:
	year = year + 1
	if year in range(1987, 2013):
		year = 2013
print(year)


def distinct(n):
	l = []
	while n > 0:
		pp = n % 10
		if pp in l:
			return False
		l.append(pp)
		n = n // 10
	return True
n = int(input())
for i in range(n + 1, 10000):
	if distinct(i) == True:
		print(i)
		break


i = int(input())
for j in range(i + 1, 10000):
	if len({j // 1000, j % 1000 // 100, j % 100 // 10, j % 10}) == 4:
		print(j)
		break


n = input()
n0 = int(n)
m = n0 + 1
A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
while True:
	t = 0
	m = str(m)
	for i in A:
		if m.count(str(i)) > 1:
			t = 1
			break
	if t == 0:
		print(m)
		break
	else:
		m = int(m) + 1


X = int(input())
while True:
	A = list(str(X + 1))
	B = []
	for x in A:
		if x not in B:
			B.append(x)
	if len(B) == len(A):
		E = X + 1
		break
	X = X + 1
print(E)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
inputYear = inp()
while True:
	inputYear += 1
	if len(set(str(inputYear))) == len(str(inputYear)):
		print(str(inputYear))
		break


a = input()
b = []
if 1000 <= int(a) <= 9000:
	for k in range(int(a) + 1, 9013):
		k = str(k)
		for i in k:
			b.append(i)
		c = set(b)
		g = len(c)
		if len(a) == g:
			print(k)
			break
		b = []


n = int(input())
f = 0
while f < 1:
	flag = 0
	n += 1
	s = str(n)
	for i in range(len(s)):
		for j in range(len(s)):
			if s[i] == s[j] and i != j:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		f = 1
print(n)


y = int(input())
arr = []
for i in range(y, 9013):
	num = i
	visited = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	while num:
		if visited[num % 10] == 1:
			break
		visited[num % 10] = 1
		num = int(num // 10)
	if num == 0:
		arr.append(i)
print(arr[list(map(lambda i: i > y, arr)).index(True)])


def jud(n):
	num = list(n)
	l = len(num)
	flagg = True
	for i in range(l):
		if num.count(num[i]) >= 2:
			flagg = False
	return flagg
y = int(input())
x = y + 1
while jud(str(x)) == False:
	x = x + 1
print(str(x))


n = int(input())
z = 1
while z == 1:
	l = []
	z = 0
	n = n + 1
	m = n
	while m > 0:
		c = m % 10
		l.append(c)
		m = m // 10
	l.sort()
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			z = 1
			break
print(n)


date = input()
date = int(date)
nd = date + 1
pall = False
while pall == False:
	nd = str(nd)
	if nd.count('1') > 1 or nd.count('2') > 1 or nd.count('3') > 1 or (nd.count('4') > 1) or (nd.count('5') > 1) or (nd.count('6') > 1) or (nd.count('7') > 1) or (nd.count('8') > 1) or (nd.count('9') > 1) or (nd.count('0') > 1):
		nd = int(nd)
		nd += 1
	else:
		pall = True
print(nd)


def year(x):
	while x <= 9999:
		x += 1
		if len(set(str(x))) == 4:
			return x
print(year(int(input())))


a = int(input())
a += 1
net = True
while net:
	x = list(str(a))
	if x[0] != x[1] and x[0] != x[2] and (x[0] != x[3]) and (x[1] != x[2]) and (x[1] != x[3]) and (x[2] != x[3]):
		net = False
		print(''.join(x))
	else:
		a += 1


num = int(input())
while True:
	num += 1
	num_1 = str(num)
	set_1 = ''.join(set(num_1))
	if len(set_1) < 4:
		continue
	else:
		print(num_1)
		quit()


s = input()

def isDistinct(n):
	for l in str(n):
		if str(n).count(l) != 1:
			return False
	return True
n = int(s)
while True:
	n += 1
	if isDistinct(n):
		print(n)
		break


k = input()
inp = [int(x) for x in k]
num = int(k) + 1
while True:
	if len(set(str(num))) == 4:
		break
	num += 1
print(num)


n = int(input())
n = str(n)
k = n
while (n[0] == n[1] or n[1] == n[2] or n[2] == n[3] or (n[0] == n[3]) or (n[0] == n[2]) or (n[1] == n[3])) or n == k:
	n = int(n)
	n += 1
	n = str(n)
print(n)


year = int(input())
while True:
	year += 1
	l = [int(x) for x in list(str(year))]
	s = list(set(l))
	if sorted(l) == sorted(s):
		break
print(year)


n = int(input())
numbs = []
for i in range(1000, 9001):
	i = str(i)
	if i.count('0') < 2 and i.count('1') < 2 and (i.count('2') < 2) and (i.count('3') < 2) and (i.count('4') < 2) and (i.count('5') < 2) and (i.count('6') < 2) and (i.count('7') < 2) and (i.count('8') < 2) and (i.count('9') < 2):
		numbs.append(int(i))
numbs.append(9012)
for i in numbs:
	if n < i:
		print(i)
		break


def uniqueDigits(x):
	arr = [0 for x in range(10)]
	while x > 0:
		arr[x % 10] += 1
		x //= 10
	for i in arr:
		if i > 1:
			return False
	return True
n = int(input())
n += 1
while uniqueDigits(n) != True:
	n += 1
print(n)


def distinct(l):
	x = set(l)
	if len(x) == 4:
		return True
	else:
		return False
year = input()
found = False
while not found:
	year = int(year)
	year += 1
	year = str(year)
	temp = []
	for y in year:
		temp.append(y)
	out = distinct(temp)
	found = out
print(year)


y = int(input())
while True:
	y += 1
	if len(str(y)) == len(set(str(y))):
		print(y)
		quit()


y = int(input())
while True:
	y += 1
	ls = []
	for i in str(y):
		if i not in ls:
			ls.append(i)
	if len(ls) == len(str(y)):
		print(y)
		exit(0)


def unq(n):
	unql = []
	for x in n:
		if x not in unql:
			unql.append(x)
	if len(unql) == len(n):
		return True
	else:
		return False
byear = lambda yr: yr if unq(list(map(int, str(yr)))) else byear(yr + 1)
n = int(input())
print(byear(n + 1))


from sys import stdin, stdout

def main():
	a = int(input()) + 1
	while len(set(str(a))) != 4:
		a += 1
	print(a)
main()


year = int(input())
stop = True
while stop:
	year = year + 1
	if len(list(str(year))) == len(set(list(str(year)))):
		stop = False
print(year)


def sol(num):
	num = int(num) + 1
	word = ''.join(set(str(num)))
	if len(word) != len(str(num)):
		return sol(int(num))
	else:
		return num
num = input()
print(sol(num))


n = int(input())

def ch(n):
	d = {}
	for x in n:
		if x in d:
			return False
		else:
			d[x] = 1
	return True
while True:
	n += 1
	if ch(str(n)):
		break
print(n)


y = int(input())
for i in range(y + 1, 10 ** 6):
	if len(set(str(i))) == len(str(i)):
		print(i)
		break


a = int(input())
i = 1
while i > 0:
	if len(list(str(a + i))) == len(set(str(a + i))):
		print(a + i)
		break
	else:
		i += 1


from math import log10, floor
year = int(input())
while True:
	year += 1
	if len(set(str(year))) == floor(log10(year)) + 1:
		break
print(year)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
while 1:
	n += 1
	a = n % 10
	a1 = n / 10
	b = int(a1 % 10)
	b1 = a1 / 10
	c = int(b1 % 10)
	c1 = b1 / 10
	d = int(c1 % 10)
	if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d):
		break
print(n)


__author__ = 'Gamoool'

def check(arg):
	if arg[0] == arg[1] or arg[0] == arg[2] or arg[0] == arg[3] or (arg[1] == arg[2]) or (arg[1] == arg[3]) or (arg[2] == arg[3]):
		return False
	else:
		return True
entry = input()
for f in range(int(entry) + 1, 10000, 1):
	if check(str(f)) is True:
		print(f)
		break


years = range(1000, 9013)
a = list(map(str, years))
d = []
for i in a:
	if i[0] != i[1] and i[0] != i[2] and (i[0] != i[3]) and (i[1] != i[2]) and (i[1] != i[3]) and (i[2] != i[3]):
		d.append(i)
diff = 0
y = int(input())
for i in d:
	diff = int(i) - y
	if diff <= 0:
		diff += y
	elif diff >= 0:
		print(y + diff)
		break


y = int(input())
y += 1
y2 = list(str(y))
while len(set(y2)) != len(y2):
	y += 1
	y2 = list(str(y))
print(y)


y = int(input())
y += 1
sy = str(y)
if sy.count(sy[0]) == 1 and sy.count(sy[1]) == 1 and (sy.count(sy[2]) == 1) and (sy.count(sy[3]) == 1):
	print(y)
else:
	while sy.count(sy[0]) != 1 or sy.count(sy[1]) != 1 or sy.count(sy[2]) != 1 or (sy.count(sy[3]) != 1):
		y += 1
		sy = str(y)
	print(y)


s = int(input())
ans = s
flag = 0
while flag == 0:
	ans = ans + 1
	l = [0 for i in range(10)]
	for d in str(ans):
		l[int(d)] += 1
		if l[int(d)] > 1:
			l = [0 for i in range(10)]
			break
	if sum(l) == 4:
		flag = 1
print(ans)


year = int(input())
while True:
	year += 1
	diff = set((i for i in str(year)))
	if len(diff) == len(str(year)):
		print(year)
		break
	else:
		continue


year = int(input()) + 1
old_year = 0

def HaveNum(x):
	if year.count(x) >= 1:
		return 1
	else:
		return 0
while True:
	lst = list(map(int, list(str(year))))
	old_year = year
	for x in lst:
		if lst.count(x) >= 2:
			year += 1
			break
	if old_year == year:
		break
print(year)


def cvbn(n):
	c = 0
	for i in range(0, 3):
		for j in range(i + 1, 4):
			if n[i] == n[j]:
				c = -1
				return 'NO'
				break
		if c == -1:
			break
	if c == 0:
		return 'YES'
n = input()
n = str(int(n) + 1)
while cvbn(n) != 'YES':
	n = str(int(n) + 1)
print(n)


y = int(input())
i = y + 1
while i > y:
	they = str(i)
	num = [they[0], they[1], they[2], they[3]]
	if len(set(num)) == 4:
		print(i)
		break
	i += 1


def is_p(x):
	for i in x:
		if x.count(i) != 1:
			return False
	return True
n = int(input()) + 1
while not is_p(str(n)):
	n += 1
print(n)


k = int(input())
f = 0
while 1:
	k += 1
	p = str(k)
	b = []
	for i in p:
		if i not in b:
			b.append(i)
		else:
			break
	else:
		f = 1
		break
print(k)


def check(s):
	l = []
	while s != 0:
		b = s % 10
		l.append(b)
		s = s // 10
	flag = 0
	for i in l:
		count = l.count(i)
		if count > 1:
			flag = 1
		else:
			continue
	return flag
s = int(input())
t = 1
while t != 0:
	s = s + 1
	t = check(s)
print(s)


def yearr(yr):
	if len(set(str(yr))) == 4:
		return True
	else:
		return False
a = int(input())
a += 1
while yearr(a) != True:
	a += 1
print(a)


i = int(input())
while True:
	i += 1
	string = str(i)
	digits = []
	for j in string:
		digits.append(j)
	if len(list(set(digits))) == 4:
		print(i)
		break


n = int(input())
d = ['0', '0', '0', '0']
from collections import Counter
k = 1
while len(list(Counter(d).keys())) != 4:
	d = []
	a = str(n + k)
	for item in a:
		d.append(item)
	k += 1
for item in d:
	print(item, end='')


import sys
n = int(input())
for i in range(n + 1, 9013):
	if len(set(str(i))) == len(str(i)):
		print(i)
		break
sys.exit(0)


n = int(input())
n += 1
a = n // 1000
b = n // 100 % 10
c = n % 100 // 10
d = n % 10 // 1
while a == b or a == c or a == d or (b == c) or (b == d) or (c == d):
	n += 1
	a = n // 1000
	b = n // 100 % 10
	c = n % 100 // 10
	d = n % 10 // 1
q = str(a) + str(b) + str(c) + str(d)
res = int(q)
print(res)


y = int(input()) + 1
while True:
	s = str(y)
	for i in s:
		if s.count(i) > 1:
			y += 1
			break
	else:
		print(y)
		break


def f(x):
	s = str(x)
	y = list(s)
	y.sort()
	if y[0] == y[1] or y[1] == y[2] or y[2] == y[3]:
		return False
	return True
x = int(input())
x = x + 1
while f(x) == False:
	x = x + 1
print(x)


x = int(input()) + 1
y = str(x)
while y.count(y[0]) + y.count(y[1]) + y.count(y[2]) + y.count(y[3]) != 4:
	x += 1
	y = str(x)
print(x)


def beautiful(s):
	i = s + 1
	while i > s:
		p = str(i)
		if len(set(p)) == len(p):
			print(i)
			break
		i += 1
a = int(input())
beautiful(a)


z = int(input())
z += 1
status = True
cek = True
while cek == True:
	for i in range(3):
		n = str(z)
		for j in range(i + 1, 4):
			if str(n[i]) == str(n[j]):
				z += 1
				status = False
				break
			if i == 2 and j == 3:
				cek = False
		if status == False:
			status = True
			break
print(z)


n = int(input())
t = n + 1

def le(t):
	k = str(t)
	return len(set(k))
while 1:
	if le(t) >= len(list(str(n))):
		print(t)
		break
	t += 1


def difNum(j):
	dif = 1
	lista = list(str(j))
	tam = len(lista)
	for l in range(0, tam - 1, 1):
		for p in range(l + 1, tam, 1):
			if lista[l] == lista[p]:
				dif = 0
	return dif
i = int(input())
diferente = 0
while diferente == 0:
	i += 1
	diferente = difNum(i)
print(i)


a = int(input())
b = dict()
a += 1
while 1:
	b[a % 10] = 1
	b[int(a / 10) % 10] = 1
	b[int(a / 100) % 10] = 1
	b[int(a / 1000) % 10] = 1
	if sum(b.values()) == 4:
		print(a)
		break
	a += 1
	b.clear()


n = int(input())
z = n
while True:
	if len(set(str(n))) != 4:
		n += 1
	elif n == z:
		n += 1
	else:
		print(n)
		break


i = int(input())
i = i + 1
while i < 9999:
	k = i // 1000
	b = (i - k * 1000) // 100
	l = (i - k * 1000 - b * 100) // 10
	m = i - k * 1000 - b * 100 - l * 10
	if k == b or k == l or k == m or (b == l) or (b == m) or (l == m):
		i = i + 1
	else:
		break
print(i)


y = int(input())
y = y + 1
while 1:
	n = list((x for x in str(y)))
	for i in range(len(n)):
		v = n.count(n[i])
		if v > 1:
			break
	else:
		print(y)
		break
	y = y + 1


start_year = input()
start_year = int(start_year)
for year in range(start_year + 1, 9013):
	y0 = year % 10
	y1 = (year % 100 - y0) // 10
	y2 = (year % 1000 - y1) // 100
	y3 = (year % 10000 - y2) // 1000
	if y0 != y1 and y0 != y2 and (y0 != y3) and (y1 != y2) and (y1 != y3) and (y2 != y3):
		print(year)
		break


def isDistint(num):
	chars = {}
	for i in str(num):
		chars.setdefault(i, 0)
		chars[i] += 1
		if chars[i] > 1:
			return False
	return True
n = input()
nn = int(n) + 1
while not isDistint(nn):
	nn += 1
print(nn)


year = int(input())
for y in range(year + 1, 9999 + 1):
	if len(set(str(y))) == len(str(y)):
		print(y)
		break


n = int(input())
num = n + 1
res = [int(x) for x in str(num)]
while len(res) != len(set(res)):
	num = num + 1
	res = [int(x) for x in str(num)]
print(num)


n = int(input())

def is_beaufiful(num):
	num = str(num)
	vals = [num.count(v) == 1 for v in num]
	return all(vals)
answer = n + 1
while not is_beaufiful(answer):
	answer += 1
print(answer)


def is_beautiful_year(year: int) -> bool:
	year_string = '%d' % year
	year_digits = set()
	for digit in year_string:
		year_digits.add(digit)
	return len(year_digits) == len(year_string)

def find_next_beautiful_year(year: int) -> int:
	next_year = year + 1
	while not is_beautiful_year(next_year):
		next_year += 1
	return next_year
print(find_next_beautiful_year(int(input())))


def year(n):
	s = str(n)
	a = ''
	for i in range(len(s)):
		if s[i] not in a:
			a += s[i]
		else:
			return year(n + 1)
	return a
n = int(input())
print(year(n + 1))


y = int(input())

def is_b_year(x):
	s = set()
	for c in str(x):
		s.add(c)
	if len(s) == 4:
		return True
	else:
		return False
for x in range(y + 1, 2 ** 31 - 1):
	if is_b_year(x):
		print(x)
		break


x = int(input())
x += 1
j = 0
while j == 0:
	z = str(x)
	y = set(z)
	a = len(z)
	b = len(y)
	if a == b:
		print(z)
		j += 1
	x += 1


y = int(input())
while y < 9012:
	y += 1
	s = str(y)
	if s[0] != s[1] and s[0] != s[2] and (s[0] != s[3]) and (s[1] != s[2]) and (s[1] != s[3]) and (s[2] != s[3]):
		print(s)
		break


from sys import stdin
from collections import Counter
N = int(stdin.readline())
N += 1
while len(set(str(N))) < 4:
	N += 1
print(N)


def does_year_have_distinct_digits(y):
	digits = []
	while y:
		digits.append(y % 10)
		y = y // 10
	Is_it = True
	for i in range(len(digits)):
		for j in range(len(digits)):
			if digits[i] == digits[j] and i != j:
				Is_it = False
				break
	return Is_it

def main():
	year = int(input())
	if 1000 <= year <= 9000:
		while True:
			if does_year_have_distinct_digits(year + 1):
				break
			year += 1
		print(year + 1)
main()


y = eval(input())
for i in range(y + 1, 10000):
	if len(set(list(str(i)))) == 4:
		print(i)
		break


a = int(input())
while True:
	a += 1
	s = str(a)
	if len({s[0], s[1], s[2], s[3]}) == 4:
		print(a)
		break


y = int(input()) + 1
y = str(y)
arr = (y[0], y[1], y[2], y[3])
while arr[0] == arr[1] or arr[0] == arr[2] or arr[0] == arr[3] or (arr[1] == arr[2]) or (arr[1] == arr[3]) or (arr[2] == arr[3]):
	y = str(int(y) + 1)
	arr = (y[0], y[1], y[2], y[3])
print(y)


y = int(input())
for x in range(y + 1, 9015):
	count = len(set(str(x)))
	if count == 4:
		break
print(x)


y = int(input())
bDistinctYear = False
while not bDistinctYear:
	y += 1
	strYear = str(y)
	if strYear[0] != strYear[1] and strYear[0] != strYear[2] and (strYear[0] != strYear[3]):
		if strYear[1] != strYear[2] and strYear[1] != strYear[3]:
			if strYear[2] != strYear[3]:
				bDistinctYear = True
print(y)


a = input()
b = set()
for i in range(int(a) + 1, 1000001):
	c = str(i)
	for j in c:
		b.add(j)
	if len(c) == len(b):
		print(i)
		break
	b = set()


seq = int(input())
while 1:
	seq += 1
	if len(set(list(str(seq)))) == 4:
		print(seq)
		break


n = int(input())
while n <= 9012:
	list1 = []
	list2 = []
	s = str(n + 1)
	for i in range(len(s)):
		list1.append(s[i])
	for i in list1:
		if i not in list2:
			list2.append(i)
	if len(list1) == len(list2):
		print(n + 1)
		break
	else:
		n = n + 1
		continue


Y = int(input())
X = Y + 1
while len(set(str(X))) < len(list(str(X))):
	X = X + 1
print(X)


o = str(input())
x = int(o)
y = int(o)
i = 0
x_digits = [0 for u in range(len(o))]
ok = True
while True:
	x += 1
	tmp = x
	i = 0
	ok = True
	while tmp != 0:
		x_digits[i] = tmp % 10
		tmp //= 10
		i += 1
	for k in range(len(x_digits)):
		for j in range(k + 1, len(x_digits)):
			if x_digits[k] == x_digits[j]:
				ok = False
				break
		if not ok:
			break
	if ok and x > y:
		print(x)
		break


n = int(input())
n += 1
while True:
	t = set()
	tt = n
	while tt != 0:
		t.add(tt % 10)
		tt //= 10
	if len(t) == 4:
		print(n)
		break
	n += 1


n = int(input())
for i in range(n + 1, 10000):
	b = list(str(i))
	c = list(set(b))
	if len(c) == 4:
		print(i)
		break
	else:
		continue


y = int(input())
for i in range(y + 1, 9013):
	k = 0
	temp = list(map(int, str(i)))
	for m in range(4):
		for n in range(4):
			if temp[m] == temp[n]:
				k += 1
	if k == 4:
		break
print(i)


def ok(d):
	ds = str(d)
	return len(ds) == len(set(list(ds)))

def main():
	d = int(input())
	d += 1
	while not ok(d):
		d += 1
	print(d)
main()


def diferentDigits(n):
	d = [0] * 10
	for k in range(len(n)):
		if d[int(n[k])] == 0:
			d[int(n[k])] = 1
		else:
			return 1
	return 0
n = input()
while True:
	n = str(int(n) + 1)
	if diferentDigits(n) == 0:
		print(n)
		break