import java.util.Scanner; public class No499 { public static void main(String[] args) { long N; Scanner sc = new Scanner(System.in); N = Long.parseLong(sc.next()); System.out.println(Long.toString(N, 7)); } }