#include<stdio.h>
#include<stdlib.h>
int f(int n){
int i;
int *s,*s0,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8,*s9;
s=(int*)malloc(100000*sizeof(int));
s0=(int*)malloc(100000*sizeof(int));
s1=(int*)malloc(100000*sizeof(int));
s2=(int*)malloc(100000*sizeof(int));
s3=(int*)malloc(100000*sizeof(int));
s4=(int*)malloc(100000*sizeof(int));
s5=(int*)malloc(100000*sizeof(int));
s6=(int*)malloc(100000*sizeof(int));
s7=(int*)malloc(100000*sizeof(int));
s8=(int*)malloc(100000*sizeof(int));
s9=(int*)malloc(100000*sizeof(int));
switch(n){
case 10:scanf("%X",&s);s9=s;
case 9:scanf("%X",&s);s8=s;
case 8:scanf("%X",&s);s7=s;
case 7:scanf("%X",&s);s6=s;
case 6:scanf("%X",&s);s5=s;
case 5:scanf("%X",&s);s4=s;
case 4:scanf("%X",&s);s3=s;
case 3:scanf("%X",&s);s2=s;
case 2:scanf("%X",&s);s1=s;
case 1:scanf("%X",&s);s0=s;break;
}
switch(n){
case 10:printf("%o\n",s9);
case 9:printf("%o\n",s8);
case 8:printf("%o\n",s7);
case 7:printf("%o\n",s6);
case 6:printf("%o\n",s5);
case 5:printf("%o\n",s4);
case 4:printf("%o\n",s3);
case 3:printf("%o\n",s2);
case 2:printf("%o\n",s1);
case 1:printf("%o\n",s0);break;
}
return 0;
}
int main(){
int i;
scanf("%d",&i);
f(i);
return 0;
}