import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); ArrayDeque deque = new ArrayDeque<>(); while (N > 0) { deque.addLast(N % 7); N /= 7; } while (!deque.isEmpty()) { long v = deque.pollLast(); System.out.print(v); } System.out.println(); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }