#include <bits/stdc++.h>
using namespace std;
int ans = 0;
void f(int n, int x = 1) {
  if (x > n) return;
  ans++;
  f(n, 10 * x), f(n, 10 * x + 1);
}
int main() {
  int n;
  cin >> n;
  f(n);
  cout << ans;
}
