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