#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(long long n, int i) { return n & (1ll << i); }
inline long long setBit(long long n, int i) {
  return n | (1ll << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1ll << i)); }
const long long mod = 1e9 + 07;
const long long mxn = 1e6 + 10;
long long n;
vector<long long> vec;
void possible(long long m) {
  if (m > n) {
    return;
  }
  vec.push_back(m);
  possible(10 * m);
  possible(10 * m + 1);
}
int main(int argc, char const *argv[]) {
  long long i, j, k, a, b, c, d, m, t, h, u, v, x, y, z;
  cin >> n;
  possible(1);
  cout << (long long)vec.size() << "\n";
  return 0;
}
