#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  v.push_back(1);
  int i = 0;
  while (true) {
    int x = v[i];
    if (x > n) {
      cout << i;
      break;
    }
    v.push_back(x * 10);
    v.push_back(x * 10 + 1);
    ++i;
  }
}
