#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  int a[11];
  a[0] = 1;
  for (int i = 1; i < 11; i++) {
    a[i] = 2 * a[i - 1];
  }
  int count = 0;
  int x = 0;
  for (int i = l - 1; i >= 0; i--) {
    if (s[i] == '4') {
      count += a[x];
    }
    if (s[i] == '7') {
      count += (2 * a[x]);
    }
    x++;
  }
  cout << count << endl;
  return 0;
}
