#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = 2e5 + 10;
ll n, cnt = 0;
void f(ll x) {
  if (x > n) return;
  if (x <= n) cnt++;
  f(x * 10);
  f(x * 10 + 1);
}
int main() {
  cin >> n;
  f(1);
  cout << cnt << endl;
}
