#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, d = 1;
  cin >> n;
  vector<long long> v;
  v.push_back(0);
  v.push_back(1);
  while (d < 1e9) {
    long long c = v.size();
    d *= 10;
    for (long long i = 0; i < c; i++) {
      v.push_back(v[i] + d);
    }
  }
  v.push_back(1e9);
  long long ct = 0;
  for (long long i = 1; i < v.size(); i++) {
    if (v[i] <= n)
      ct++;
    else
      break;
  }
  cout << ct;
}
