#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
char s[1001] = {0}, s1[1001] = {0},temp;
long long n = 0,a = 0,nn=0,t = 0,i,lengh = 0;
scanf("%s",s);//读入8进制字符串
lengh = strlen(s);
for (i = 0; i < lengh/2; i++)
{
temp = s[i];
s[i] = s[lengh - i - 1];
s[lengh - i - 1] = temp;
}//倒置8进制字符串
for (i = 0; i < lengh; i++)
{
n += (s[i] - 48) * pow(8, i);
}//转化成10进制数字
nn = n;
i = 0;
while (nn)
{
t = nn % 16;
if (t >= 10)
s1[i] = t + 87;
else
s1[i] = t + 48;
nn = nn / 16;
i++;
}//10进制转化成16进制储存为字符串(逆序)
for ( i =0;i<strlen(s1)/2;i++)
{
temp = s1[i];
s1[i] = s1[strlen(s1) - i - 1];
s1[strlen(s1) - i - 1] = temp;
}//字符串倒置
if (n == 0)
s1[0] = '0';
printf("%s",s1);//输出结果
return 0;
}