package no294; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; for(int i=2;;i++) { int five = Integer.bitCount(i); int three = 32 - Integer.numberOfLeadingZeros(i) - five; // System.out.println(Integer.toBinaryString(i) + ":" + three + "," + five); // System.out.println(Integer.toBinaryString(i).replace('0', '3').replace('1', '5').substring(1) + "5"); if (five % 3 == 0) { count++; } if (count == n) { System.out.println(Integer.toBinaryString(i).replace('0', '3').replace('1', '5').substring(1) + "5"); return; } } } }