#include <bits/stdc++.h>
using namespace std;
bool isEqual(string str1, string str2) {
  if (str1.length() != str2.length()) return false;
  for (int64_t i = 0; i < str1.length(); i++) {
    if (str1[i] != str2[i]) return false;
  }
  return true;
}
void solve() {
  string n;
  cin >> n;
  deque<string> d;
  d.push_back("4");
  d.push_back("7");
  int64_t count = 0;
  while (1) {
    string str = d.front();
    count++;
    d.pop_front();
    if (isEqual(str, n)) {
      cout << count;
      return;
    }
    d.push_back(str + "4");
    d.push_back(str + "7");
  }
}
int32_t main() { solve(); }
