#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, m = 0, l = 0, k = 0;
  char a = '4', b = '7';
  vector<string> buf;
  string s1 = "", s2 = "";
  cin >> s1;
  if (s1 == "4") {
    cout << 1;
    return 0;
  }
  if (s1 == "7") {
    cout << 2;
    return 0;
  }
  l = s1.size();
  buf.push_back("4");
  buf.push_back("7");
  for (int i = 0; i < l; i++) {
    n = buf.size();
    for (int j = k; j < n; j++) {
      s2 = buf[j] + a;
      if (s1 == s2) {
        m++;
        i = l;
        break;
      }
      buf.push_back(s2);
      s2 = buf[j] + b;
      buf.push_back(s2);
      if (s1 == s2) {
        m += 2;
        i = l;
        break;
      }
      m += 2;
    }
    k = n;
  }
  cout << m + 2;
}
