#include <bits/stdc++.h>
using namespace std;
int main() {
  string str[1025];
  for (int i = 1; i <= 1024; i++) {
    string temp = "";
    int fuck = i;
    while (fuck > 0) {
      temp += fuck % 2 + '0';
      fuck /= 2;
    }
    reverse(temp.begin(), temp.end());
    str[i] = temp;
  }
  sort(str, str + 1025);
  long long int a[1025];
  for (int i = 1; i <= 1024; i++) {
    a[i] = stoll(str[i]);
  }
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i <= 1024; i++) {
    if (n >= a[i]) {
      ++count;
    }
  }
  cout << count;
}
