#include <bits/stdc++.h>
using namespace std;
int num(int n) {
  int k = 0, m = 4, p = 1, t = n;
  if (!n)
    return 0;
  else if (n < 10)
    return 1;
  else if (n == 10)
    return 2;
  else if (n < 100)
    return 3;
  else if (n == 100)
    return 4;
  else {
    while (n > 9) {
      n /= 10;
      k++;
      p *= 10;
    }
    k--;
    while (k--) m *= 2;
    if (n > 1)
      return m - 1;
    else if (!n)
      return 0;
    else {
      t %= p;
      return m / 2 + num(t);
    }
  }
}
int main() {
  int n;
  cin >> n;
  cout << num(n) << endl;
  return 0;
}
