#include <bits/stdc++.h>
using namespace std;
long long a[35];
long long p[15];
long long n, i, j, k, x, s, m;
int main() {
  cin >> n;
  a[0] = 1;
  for (i = 1; i < 10; i++) {
    a[i] = a[i - 1] * 2;
  }
  m = n;
  while (m > 0) {
    m /= 10;
    s++;
  }
  m = 0;
  k = a[s];
  x = 1;
  while (n > 0) {
    m = 10 * m + n % 10;
    n /= 10;
  }
  n = m;
  while (n > 0) {
    if (n % 10 == 7) x += k / 2;
    k /= 2;
    n /= 10;
  }
  cout << 2 * a[s - 1] - 2 + x << endl;
  return 0;
}
