#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<long long int> ans;
void go(long long int a = 1) {
  if (n < a) return;
  ans.push_back(a);
  go(a * 10);
  go(a * 10 + 1);
}
void solve() {
  cin >> n;
  go();
  cout << ans.size() << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
