#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long digits[9];
  memset(digits, 0, sizeof(digits));
  long long curdigit = 0;
  while (n) {
    digits[curdigit] = n % 10;
    n /= 10;
    curdigit++;
  }
  long long firstdigit = curdigit - 1;
  long long ans = 0;
  for (long long i = firstdigit; i >= 0; i--) {
    if (digits[i] > 1) {
      ans += pow(2, i + 1) - 1;
      break;
    } else if (digits[i] == 1) {
      ans += pow(2, i);
    }
  }
  cout << ans << "\n";
}
