#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long b, c, digit, d, count = 0;
  for (long long a = 1; a < pow(2, 10); a++) {
    b = a;
    c = 1;
    digit = 0;
    while (b) {
      digit += c * ((b % 2));
      c *= 10;
      b /= 2;
    }
    if (digit <= n) {
      count++;
    } else {
      break;
    }
  }
  cout << count;
}
