#include<iostream>using namespace std;int main(){int i,j=0,k=1;cin>>i;while(i)
{j=k*(i%10);k*=8;i=i/10;
}cout<<j<<endl;return 0;
}