One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.

But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input

Input data contains the only number n (1 ≤ n ≤ 109).

Output

Output the only number — answer to the problem.

Examples

Input

10


Output

2

Note

For n = 10 the answer includes numbers 1 and 10.
#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    long long n;
    cin >> n;
    long long temp = n;
    long long len = 0;
    while (temp) {
      ++len;
      temp /= 10;
    }
    long long foo = n;
    vector<long long> v;
    v.clear();
    while (foo) {
      long long x = foo % 10;
      foo /= 10;
      v.push_back(x);
    }
    vector<long long> vec;
    vec.clear();
    long long j = 0;
    for (long long i = v.size() - 1; i >= 0; --i) {
      vec.push_back(v.at(i));
    }
    v.clear();
    v = vec;
    vector<long long> vx;
    vx.clear();
    for (long long i = 0; i < v.size(); ++i) {
      if (v[i] == 0) {
        long long x = 0;
        vx.push_back(x);
        continue;
      } else if (v[i] == 1) {
        long long x = 1;
        vx.push_back(x);
        continue;
      } else if (v[i] >= 2) {
        for (long long j = i; j < v.size(); ++j) {
          long long x = 1;
          vx.push_back(x);
        }
        break;
      }
      break;
    }
    v.clear();
    v = vx;
    long long cnt = 0;
    if (n <= 9) {
      cout << 1 << endl;
      return 0;
    } else if (n == 10) {
      cout << 2 << endl;
      return 0;
    } else if (n >= 11 && n <= 99) {
      cout << 3 << endl;
      return 0;
    }
    long long dp[100];
    dp[1] = 1;
    for (long long i = 2; i <= 9; ++i) {
      dp[i] = pow(2, i);
    }
    long long tot = 0;
    if (len >= 3) {
      long long res = len;
      for (long long i = 0; i < v.size(); ++i) {
        if (v[i] == 0) {
          --res;
          continue;
        } else if (v[i] >= 1) {
          tot += pow(2, res - 1);
          --res;
        }
      }
    }
    cout << tot << endl;
    return 0;
  }
}
