#include <bits/stdc++.h>
using namespace std;
int n, k, sum, j, i, v;
string s;
int main() {
  cin >> s;
  n = 1;
  k = s.size();
  for (j = 0; j < s.size(); j++) {
    k--;
    if (s[j] > '1') {
      for (v = 0; v < s.size(); v++) s[v] = '1';
    }
    if (s[j] > '0') {
      for (i = k; i > 0; i--) n *= 2;
      sum += n;
      n = 1;
    }
  }
  cout << sum;
}
