#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int main() {
  int n;
  cin >> n;
  vector<int> bin(1025);
  int idx = 1;
  queue<int> q;
  bin[0] = 0;
  q.push(1);
  for (int i = 0; i <= 1024; ++i) {
    int num = q.front();
    q.pop();
    bin[idx++] = num;
    q.push(num * 10 + 0);
    q.push(num * 10 + 1);
  }
  int r = lower_bound(bin.begin(), bin.end(), n) - bin.begin();
  if (bin[r] != n) r--;
  cout << r << endl;
}
