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