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;
long long int MOD = 998244353;
long long int mod = 1e9 + 7;
const int N = 101;
int visited[N];
vector<long long int> grph[N];
long long int level[N];
long long int parent[N];
int dist[N];
long long int pred[N];
void dfs(int curr) {
  visited[curr] = 1;
  for (auto i : grph[curr]) {
    if (visited[i] == 1) {
      continue;
    }
    dfs(i);
  }
}
bool bfs(long long int x, long long int dest) {
  queue<long long int> q;
  q.push(x);
  while (!q.empty()) {
    long long int curr = q.front();
    q.pop();
    for (auto z : grph[curr]) {
      if (visited[z] == 0) {
        visited[z] = 1;
        dist[z] = dist[curr] + 1;
        pred[z] = curr;
        q.push(z);
        if (z == dest) return true;
      } else
        continue;
    }
  }
  return false;
}
bool sortbysec(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return (a.second < b.second);
}
long long int find(long long int x) {
  if (parent[x] == x)
    return x;
  else
    return parent[x] = find(parent[x]);
}
long long int modinverse(long long int a, long long int m) {
  long long int m0 = MOD;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
unsigned long long power(unsigned long long x, long long int y,
                         long long int p) {
  unsigned long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unsigned long long modInverse(unsigned long long n, int p) {
  return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n, int r, int p) {
  if (r == 0) return 1;
  unsigned long long fac[n + 1];
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
long long factorial(int n) {
  const unsigned int M = 1000000007;
  unsigned long long f = 1;
  for (int i = 1; i <= n; i++) f = ((f % M) * (i % M)) % M;
  return f;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int tt;
  tt = 1;
  while (tt--) {
    long long int n, pos2 = -1, k, pos1 = -1, l, p, q, i, j, m, ans = 0,
                     res = 0, cnt = 0, cnt1 = 0, cnt0 = 0, f = 0, sum = 0,
                     minn = INT_MAX, maxx = INT_MIN;
    cin >> n;
    queue<long long int> qu;
    qu.push(1);
    while (!qu.empty()) {
      ans = qu.front();
      if (ans <= n) res++;
      qu.pop();
      if (ans <= n) {
        qu.push(10 * ans);
        qu.push(10 * ans + 1);
      }
    }
    cout << res << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
