#include <bits/stdc++.h>
using namespace std;
int n;
int bas[1000001];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int i = 0;
  while (n) {
    bas[i++] = n % 10;
    n /= 10;
  }
  bas[i] = -1;
  long long s = 0;
  if (i >= 1) s += (1 << i) - 2;
  for (int j = i - 1; j >= 1; j--) {
    if (bas[j] == 7) s += (1 << (j));
  }
  if (bas[0] == 7) s += 2;
  if (bas[0] == 4) s += 1;
  cout << s << endl;
  return 0;
}
