#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <map>
//#include <set>
#include <utility>
#include <iterator>
#include <array>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <climits>
#include <cstring>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
string addBinary(string a, string b) {
    if (a.size() < b.size()) {
        swap(a, b);
    }
    int lena = a.size();
    int lenb = b.size();
    if (lenb == 0) {
        return a;
    }
    string ret;
    unsigned short c = 0;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    int i = 0, j = 0;
    for (; i < lena && j < lenb; ) {
        char cha = a[i], chb = b[j];
        unsigned short sum = cha - '0' + chb - '0' + c;
        c = sum / 2;
        ret.push_back(sum % 2 + '0');
        ++i, ++j;
    }
    int k = i;
    for (; k < lena; ++k) {
        unsigned short sum = a[k] - '0' + c;
        c = sum / 2;
        ret.push_back(sum % 2 + '0');
    }
    if (c == 1) {
        ret.push_back('1');
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int cal(int n){
    return pow(2, n - 1);
}
int main(int argc, char *argv[])
{
    string a = "111";
    string b = "1";
    auto ret = addBinary(a,b);
    freopen("input.txt", "r", stdin);
    unsigned int n = 0;
    while (cin >> n) {
        stringstream sstrm;
        sstrm << n;
        string str;
        sstrm >> str;
        int sz = str.size();
        string ss(sz, '1');
        sstrm.str("");
        sstrm.clear();
        sstrm.str(ss);
        int num = 0;
        sstrm >> num;
        int ret = 0;
        if (n >= num) {
            for (int i = 1; i <= sz; ++i) {
                ret += cal(i);
            }
        } else {
            for (int i = 1; i <= sz - 1; ++i) {
                ret += cal(i);
            }
            string basestr(sz,'0');
            basestr[0] = '1';
            int tempnum = stoi(basestr);
            while (tempnum <= n) {
                ++ret;
                basestr = addBinary(basestr,"1");
                tempnum = stoi(basestr);
            }
        }
        cout << ret << endl;
    }
    return 0;
}
第一道覆盖了,没存下来