import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); long N = Long.parseLong(reader.readLine()); System.out.println(toSeptenaryString(N)); } private static String toSeptenaryString(long l) { StringBuilder s = new StringBuilder(); if(l ==0) { return "0"; } while (l != 0) { s.append(l % 7); l = l / 7; } return s.reverse().toString(); } }