#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
void solve(int p, long long g) {
  a.push_back(g);
  if (p >= 10) return;
  solve(p + 1, g * 10 + 1);
  solve(p + 1, g * 10 + 0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve(0, 0);
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  long long n;
  cin >> n;
  auto p = upper_bound(a.begin(), a.end(), n) - a.begin();
  cout << p - 1 << '\n';
  return 0;
}
