#include <bits/stdc++.h>
using namespace std;
int ans = 0, n;
void rec(int a) {
  ans++;
  if (a * 10 <= n) rec(a * 10);
  if (a * 10 + 1 <= n) rec(a * 10 + 1);
  return;
}
void solve() {
  cin >> n;
  rec(1);
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
