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; while(tmp>6){ tmp = tmp/7; System.out.print(tmp); } System.out.println(mod); } }