N = int(input())
num = 666
count =0
while 1:
if '666' in str(num):
count+=1
if count == N:
print(num)
break
num+=1
"""
for i in range(5):
for j in range(5):
if i==0:
if j==0:
a.append(666)
else:
for k in range(10**j):
k = str(k)
a.append(int('666'+'0'*(j-len(k))+k))
elif j==0:
for k in range(10**(i-1),10**i):
k = str(k)
a.append(int(k+'666'))
else:
for p in range(10**(i-1),10**i):
p=str(p)
for q in range(10**j):
q=str(q)
a.append(int(p+'666'+'0'*(j-len(q))+q))
a=list(set(a))
a.sort()
print(a[N-1])
"""
'Algorithm > Baekjoon' 카테고리의 다른 글
2108번 (0) | 2021.05.15 |
---|---|
10989 (0) | 2021.05.15 |
7568 (0) | 2021.05.10 |
2231 (0) | 2021.05.09 |
2798 (0) | 2021.05.09 |