#include<bits/stdc++.h>
using namespace std;
int main(){
     
    string s;
    cin>>s; 
    long long  k=1,ans=0;
    for(int i=s.size()-1;i>=0;i--){
        ans=ans+(s[i]-'0')*k;
        k=k*8;
    }
    cout<<ans;
 
}
/**************************************************************
	Problem: 1291
	User: lijinkai
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2076 kb
****************************************************************/