#include <bits/stdc++.h>
int main() {
  int n, m;
  long long b(1);
  std::vector<long long> v = {{0, 1}};
  std::scanf("%d", &n);
  for (int i(0); i < 10; ++i) {
    b *= 10;
    m = v.size();
    for (int j(0); j < m; ++j) {
      v.push_back(b + v[j]);
    }
  }
  m = (int)(std::upper_bound(v.begin(), v.end(), (long long)n) - v.begin()) - 1;
  std::printf("%d\n", m);
  return 0;
}
