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 gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T1, class T2>
struct cmpf {
  bool rev;
  inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
    return (a.first < b.first) ^ rev;
  }
  cmpf(bool b = false) { rev = b; }
};
template <class T1, class T2>
struct cmps {
  bool rev;
  inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
    return (a.second < b.second) ^ rev;
  }
  cmps(bool b = false) { rev = b; }
};
string to_string(const char& c) { return string(1, c); }
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(const bool& b) { return (b ? "true" : "false"); }
string to_string(const vector<bool>& v, const string& sep = " ") {
  string s = "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) {
      s += sep;
    }
    s += to_string(v[i]);
  }
  return s + "]";
}
template <size_t N>
string to_string(const bitset<N>& v) {
  string s = "[";
  for (size_t i = 0; i < N; i++) s += v[i] ? '1' : '0';
  return s + "]";
}
template <class T1, class T2>
string to_string(const pair<T1, T2>& p, const string& sep = ",");
template <class T>
string to_string(const T& v, const string& sep = " ") {
  bool first = true;
  string s = "{";
  for (const auto& x : v) {
    if (!first)
      s += sep;
    else
      first = false;
    s += to_string(x);
  }
  return s + "}";
}
template <class T>
string to_string(const T& v, const int& sz, const string& sep = " ") {
  string s = "[";
  for (int i = 0; i < sz; i++) {
    if (i) {
      s += sep;
    }
    s += to_string(v[i]);
  }
  return s + "]";
}
template <class T1, class T2>
string to_string(const pair<T1, T2>& p, const string& sep) {
  return "(" + to_string(p.first) + sep + to_string(p.second) + ")";
}
long long binpow(const long long& x, const long long& p, const long long& mod) {
  assert(mod > 0);
  if (p == 0) return 1;
  if (p == 1) return x % mod;
  if (p & 1) return (binpow((x * x) % mod, p / 2, mod) * x) % mod;
  return binpow((x * x) % mod, p / 2, mod) % mod;
}
template <class T>
void chmn(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmx(T& a, const T& b) {
  if (a < b) a = b;
}
void setIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
int chr[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int chc[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const long long MOD = 1e9 + 7;
const int INIT = 1001001001;
const int MN = -1;
int N;
int rec(int n) {
  if (n > N) return 0;
  return 1 + rec(n * 10) + rec(n * 10 + 1);
}
void solve() {
  cin >> N;
  cout << rec(1);
}
int main() {
  setIO();
  long long T = 1;
  while (T--) solve();
  return 0;
}
