#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pow2(int a)
{
if(a)return 1<<a;
return 1;
}
ll pow3(int a)
{
if(a)return 1<<a;
return 0;
}
ll f(string x)
{
ll j;
if(x=="0")return 1;
if(x=="1")return 2;
if(x[0]=='0')j=(1<<((int)x.length()))-2;
else j=(1<<((int)x.length()-1))+(1<<((int)x.length()))-2;
j++;
reverse(x.begin(),x.end());
int l=x.length()-1;
for(int i=0;i<l;i++)
if(x[i]=='1')j+=pow2(i);
return j;
}
int main()
{
char ch;
string s="";
while(cin>>ch)ch=='4' ? s+='0' : s+='1';
cout<<f(s);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKbGwgcG93MihpbnQgYSkKewogICAgaWYoYSlyZXR1cm4gMTw8YTsKICAgIHJldHVybiAxOwp9CmxsIHBvdzMoaW50IGEpCnsKCWlmKGEpcmV0dXJuIDE8PGE7CglyZXR1cm4gMDsKfQpsbCBmKHN0cmluZyB4KQp7CiAgICBsbCBqOwogICAgaWYoeD09IjAiKXJldHVybiAxOwogICAgaWYoeD09IjEiKXJldHVybiAyOwogICAgaWYoeFswXT09JzAnKWo9KDE8PCgoaW50KXgubGVuZ3RoKCkpKS0yOwogICAgZWxzZSBqPSgxPDwoKGludCl4Lmxlbmd0aCgpLTEpKSsoMTw8KChpbnQpeC5sZW5ndGgoKSkpLTI7CiAgICBqKys7CiAgICByZXZlcnNlKHguYmVnaW4oKSx4LmVuZCgpKTsKICAgIGludCBsPXgubGVuZ3RoKCktMTsKICAgIGZvcihpbnQgaT0wO2k8bDtpKyspCiAgICAgICAgaWYoeFtpXT09JzEnKWorPXBvdzIoaSk7CiAgICByZXR1cm4gajsKfQoKCmludCBtYWluKCkKewogICAgY2hhciBjaDsKICAgIHN0cmluZyBzPSIiOwogICAgd2hpbGUoY2luPj5jaCljaD09JzQnID8gcys9JzAnIDogcys9JzEnOwogICAgY291dDw8ZihzKTsKICAgIHJldHVybiAwOwp9Cg==