#include <iostream>
#include <queue>
int look(int n) {
    int count = 0;
    std::queue<long long> q;
    q.push(1);

    while (!q.empty()) {
        long long num = q.front();
        q.pop();

        if (num <= n) {
            count++;
            q.push(num * 10);
            q.push(num * 10 + 1);
        }
    }

    return count;
}

int main() {
    int n;

    std::cin >> n;
    int result = look(n);
    std::cout << result << std::endl;
    return 0;
}    

0 comments

No comments so far...