#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
queue<int> q;
int main() {
  int n;
  cin >> n;
  while (!q.empty()) q.pop();
  int ans = 0;
  q.push(1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (x > n) continue;
    q.push(x * 10);
    q.push(x * 10 + 1);
    ans++;
  }
  cout << ans << endl;
  return 0;
}
