#include <bits/stdc++.h>
using namespace std;
int n;
int solve(int i) {
  if (i > n) {
    return 0;
  }
  return 1 + solve(i * 10) + solve(i * 10 + 1);
}
int main() {
  cin >> n;
  cout << solve(1) << endl;
}
