#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 10000000079) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 100;
  string n;
  cin >> n;
  long long ans = 0, flag = 0;
  for (int i = 0; i < n.length(); i++) {
    if (n[i] == '1') {
      ans += powm(2, n.length() - 1 - i);
    } else if (n[i] > '1') {
      ans += powm(2, n.length() - i);
      flag = 1;
      break;
    }
  }
  if (flag) ans--;
  cout << ans << '\n';
}
