#include <iostream>
#include <string>
using namespace std;

string str1;
int main() 
{
    int w,ans;
    ios::sync_with_stdio(false);
    while(cin>>str1)
    {
        w=1;ans=0;
        for(int i=str1.size()-1;0<=i;--i)
        {
            w=w<<1;
            ans+=(str1[i]-'0')*(w-1);
        }
        cout<<ans<<endl;
    }
    
    return 0;
}
// 64 位输出请用 printf("%lld")