#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
int j = 0;
cin >> n;
int nn = 0;
while (n)
{
j += (n % 10) * pow(8, nn);
n = n / 10;
nn++;
}
cout << j << endl;
return 0;
}