import java.util.Scanner;
import java.lang.Integer;
public class java {
public static void main(String[] args) {
Scanner time=new Scanner(System.in);
int a;
while(time.hasNext())
{
a=time.nextInt();
if(a<0){
System.out.println("-1");
}else{
System.out.println(Integer.toOctalString(a)); //10進位轉成8進位
}
}
}
}