import java.util.Scanner; public class Main_yukicoder294 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int cnt = 0; out: for (int i = 1; i < 26; i++) { for (int k = 0; k < 0x1 << i; k++) { int tmp = 0; for (int l = i - 1; l >= 0; l--) { if ((k & 0x1 << l) == 0) { tmp += 3; } else { tmp += 5; } } if (tmp % 3 == 0 && (k & 0x1) != 0) { cnt++; if (cnt == n) { String btmp = ""; for (int l = i - 1; l >= 0; l--) { if ((k & 0x1 << l) == 0) { btmp += "3"; } else { btmp += "5"; } } System.out.println(btmp.toString()); break out; } } } } sc.close(); } }