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 = Integer.bitCount(k) * 5 + (i - Integer.bitCount(k)) * 3; 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(); } }