#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int sz = (cin >> s, s.size()), cnt = 0;
  for (int i = 0; i < sz; i++)
    if (s[i] > '1') {
      for (int j = i; j < sz; j++) s[j] = '1';
      break;
    }
  while (sz > 1) {
    cnt += pow(2, sz - 1);
    s[0] = '0';
    while (s.size() > 1 && (s[0] == '0')) s.erase(0, 1);
    sz = s.size();
  }
  cnt += s == "0" ? 0 : 1;
  cout << cnt;
}
