#include <bits/stdc++.h>
const double e = 1e-7;
const int N = 111;
const long long mod = 1000000007;
using namespace std;
vector<long long> numbers;
void BACKTRACK(long long num, int i) {
  if (i == 10) return;
  numbers.push_back(num);
  BACKTRACK(num * 10, i + 1);
  BACKTRACK(num * 10 + 1, i + 1);
}
int main() {
  long long n;
  cin >> n;
  BACKTRACK(1, 0);
  sort(numbers.begin(), numbers.end());
  int k = 0;
  while (k < numbers.size() && numbers[k] <= n) ++k;
  cout << k << endl;
}
