import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; int x = 0; int length = 1; while (count < n) { x = 0; while (count < n && x < (1 << length) - 1) { x++; if (isSuper(x)) { count++; } } length++; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < length - 1; i++) { if ((x & 1L) == 0) { sb.append("3"); } else { sb.append("5"); } x >>= 1; } sb.reverse(); System.out.println(sb + "5"); } static boolean isSuper(long x) { long count = 0; while (x > 0) { count += (x & 1L); x >>= 1; } return (count % 3 == 2); } }