#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  queue<long long> q;
  int coun = 0;
  q.push(1);
  long long top = q.front();
  while (top <= n) {
    top = q.front();
    if (top > n) break;
    q.pop();
    q.push(top * 10);
    q.push(top * 10 + 1);
    coun++;
  }
  cout << coun;
  return 0;
}
