#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string skew;
while (cin >> skew)
{
reverse(skew.begin(), skew.end());
int res = 0;
for (int i = 0; i < skew.size(); ++i)
res += (skew[i]-'0') * ((2 << i) - 1); //并不需要去用pow,2的次方直接用位运算即可
cout << res << endl;
}
return 0;
}