import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args){ Scanner s = new Scanner(System.in); String str = s.next(); s.close(); long l = Long.parseLong(str); long ltmp = l; Stack stack = new Stack(); while(true){ stack.push(ltmp%7); if(ltmp/7 < 7){ stack.push(ltmp/7); break; } ltmp = ltmp/7; } long ans = 0; long pow = stack.size()-1; while(!stack.empty()){ ans += stack.pop()* (long)Math.pow(10, pow); pow--; } System.out.println(ans); } }