// 状态当前所处位置,
// 选择:左下、下方、右下
//目标:到最后一层总和最大
//dp定义:走到i,j时最大得分
// dp[i][j] = Math.max(dp[i-1][j-1],dp[i-1][j],dp[i-1][j+1]) + grid[i][j] ;
//base: i = 0: -min -
import java.util.*;
public class Main {
public static void main(String[] args) {
// 京东第一题
Scanner sc = new Scanner(System.in) ;
int n = sc.nextInt() ;
int res = 0 ;
Queue<Integer> queue = new LinkedList<>() ;
queue.add(2) ;
queue.add(3) ;
queue.add(5) ;
int temp = 0 ;
while(res < n){
temp = queue.poll() ; res ++ ;
// 将所有的子节点入队
queue.add(temp * 10 + 2 ) ;
queue.add(temp * 10 + 3 ) ;
queue.add(temp * 10 + 5 ) ;
}
System.out.print(temp);
}
/**
Scanner sc = new Scanner(System.in) ;
int n = sc.nextInt() ;
int[][] grid = new int[n][2*n-1] ;
for(int i = 1 ; i < n + 1 ; i++ ) { // 层数
for(int j = 0; j < 2*i -1; j++){
grid[i-1][j] = sc.nextInt() ;
}
}
for(int i = 1; i < n; i ++){
for(int j = 0; j < 2*n - 1 ; j ++){
if(j - 1 == -1){
grid[i][j] = Math.max(grid[i-1][j],grid[i-1][j+1] ) + grid[i][j] ;
} else if(j + 1 == 2*n -1 ){
grid[i][j] = Math.max(grid[i-1][j - 1],grid[i-1][j] ) + grid[i][j] ;
} else {
grid[i][j] = Math.max(Math.max(grid[i - 1][j - 1], grid[i - 1][j]), grid[i - 1][j + 1]) + grid[i][j];
}
}
}
int max = 0 ;
for(int i = 0; i < 2*n -1; i ++){
if(grid[n-1][i] > max){
max = grid[n-1][i] ;
}
}
System.out.print(max);
}
**/
}
#笔试题目##京东#