#include <bits/stdc++.h>
using namespace std;
int finddigits(int n) {
  int countt = 0;
  while (n > 0) {
    countt++;
    n = n / 10;
  }
  return countt;
}
int findcount(int n) {
  int countt = finddigits(n);
  int temp = 0, p = 0;
  int i = 0, a[countt], k = 0;
  while (n > 0) {
    temp = n % 10;
    if (temp == 4) {
      k = 0;
    } else if (temp == 7) {
      k = 1;
    }
    a[i] = k;
    n = n / 10;
    i++;
  }
  int res = 0;
  res = pow(2, countt) - 1;
  int c2 = 0;
  for (int i = 0; i < countt; i++) {
    c2 = c2 + a[i] * pow(2, i);
  }
  res = res + c2;
  return res;
}
int main() {
  int n;
  cin >> n;
  cout << findcount(n) << endl;
  return 0;
}
