#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long k;
  int i, count = 0;
  for (int j = 1; j <= pow(2, 10); j++) {
    int a = j;
    k = 0;
    i = 1;
    while (a > 0) {
      if (a & 1) k += i;
      a >>= 1;
      i *= 10;
    }
    if (k > n)
      break;
    else
      count++;
  }
  cout << count;
}
