#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
ull pow2(ull n) { return 1 << n; }
ull Plus1(ull n) {
  int a = 1, k = 0;
  while (n % 10 == 1) {
    n /= 10;
    k++;
  }
  n++;
  for (int i = 1; i <= k; i++) n *= 10;
  return n;
}
int main() {
  int n;
  cin >> n;
  int a = 1;
  int ans = 0;
  while (int(log10(a)) < int(log10(n))) {
    ans += pow2(int(log10(a)));
    a *= 10;
  }
  while (a <= n) {
    a = Plus1(a);
    ans++;
  }
  cout << ans;
}
