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

int main() {
    string x;
    while (getline(cin, x)) {
        int n = 0;  // 初始化 n
        for (int i = 0; i < x.size(); ++i) {
            n += (x[i]-'0') * (pow(2, x.size() - i) - 1);
        }//(x[i]-'0')可以将char表示的数字强转为对应数字,pow是cmath库中的指数运算
        cout << n << endl;
    }
    return 0;
}