import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); if(N == 0) { System.out.println(0); } else { String ans = ""; while(N > 0) { int r = N % 7; ans = String.valueOf(r) + ans; N -= r; N /= 7; } System.out.println(ans); } } }