f=[]
def cl(x):
global f
f=[]
while x>0:
s=x%10
if s not in f:
f.append(s)
x//=10
def check(x):
global f
while x>0:
s=x%10
if s not in f:
return False
x//=10
return True
for i in range(1,1000000):
cl(i)
if check(2*i) and check(3*i) and check(4*i) and check(5*i) and check(6*i):
print(i)