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 int mod = 998244353;
int chkpower2(int x) { return (x && !(x & x - 1)); }
vector<long long int> primeFactors(long long int n) {
  vector<long long int> v;
  while (n % 2 == 0) {
    v.push_back(2);
    n = n / 2;
  }
  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      v.push_back(i);
      n = n / i;
    }
  }
  v.push_back(n);
  return v;
}
long long int power(long long int a, long long int b) {
  long long int i = 0;
  long long int c = 1;
  for (i = 0; i < b; i++) {
    c = c * a;
    c = c % mod;
  }
  return c;
}
int ans = 0;
vector<int> num;
void rec(vector<int> v) {
  int i;
  if (v.size() > num.size()) {
    return;
  }
  if (v.size() < num.size()) {
    ans++;
    v.push_back(0);
    rec(v);
    v.pop_back();
    v.push_back(1);
    rec(v);
    return;
  }
  for (i = 0; i < v.size(); i++) {
    if (num[i] > v[i]) {
      break;
    }
    if (num[i] < v[i]) {
      return;
    }
  }
  ans++;
  v.push_back(0);
  rec(v);
  v.pop_back();
  v.push_back(1);
  rec(v);
  return;
}
void solve() {
  int n, i, j, k;
  cin >> n;
  string s = to_string(n);
  for (i = 0; i < s.size(); i++) {
    int x = (int)(s[i] - '0');
    num.push_back(x);
  }
  vector<int> v;
  v.push_back(1);
  rec(v);
  cout << ans;
  return;
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
