import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
T t = new T();
t.t(n);
}
}
class T {
public void t(int n) {
if(n > 5) {
t(n / 6);
}
System.out.print(n % 6);
}
}