#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-11;
const int inf = (int)2e9;
const int mod = (int)1e9 + 7;
const int N = 123456;
int n;
int ans;
int a[10];
void Back(int k, int l) {
  if (k == l) {
    long long cur = 0;
    for (int i = 0; i < l; i++) cur = cur * 10 + a[i];
    if (cur <= n) ans++;
  } else {
    for (int i = 0; i < 2; i++) {
      a[k] = i;
      Back(k + 1, l);
    }
  }
}
int main() {
  cin >> n;
  Back(0, 10);
  cout << ans - 1 << endl;
  return 0;
}
