#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  vector<string> v;
  unordered_set<string> st;
  string start = "";
  queue<string> q;
  q.push(start);
  while (!q.empty()) {
    string cur = q.front();
    q.pop();
    if (cur.size() > s.size() || st.count(cur)) continue;
    st.insert(cur);
    q.push(cur + "4");
    if (!st.count(cur + "4")) v.push_back(cur + "4");
    q.push(cur + "7");
    if (!st.count(cur + "7")) v.push_back(cur + "7");
  }
  int x = find((v).begin(), (v).end(), s) - v.begin();
  cout << x + 1;
}
