import java.util.*; class Main{ public static void main(String args[]){ Scanner cin = new Scanner(System.in); int target = cin.nextInt(); int tmp = target; while(tmp>8){ if(tmp==7){ System.out.print(1); tmp=0; }else{ tmp = tmp/7; System.out.print(tmp); } } System.out.println(tmp); } }