#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, cnt = 1;
  ;
  cin >> n;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (10 * t > n)
      break;
    else {
      q.push(10 * t);
      cnt++;
    }
    if ((10 * t + 1) > n)
      break;
    else {
      q.push(10 * t + 1);
      cnt++;
    }
  }
  cout << cnt << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
}
