#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long ans = 0;
  int n = s.size();
  for (int i = 1; i < n; i++) ans += (1 << i);
  for (int i = 0; i < (1 << n); i++) {
    int found = 1;
    string temp = "";
    for (int j = s.size() - 1; j >= 0; j--) {
      if (1 & (i >> j))
        temp += '1';
      else
        temp += '0';
    }
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '4' && temp[j] == '1') found = 0;
      if (s[j] == '7' && temp[j] == '0') found = 0;
    }
    if (found) {
      cout << ans + i + 1 << endl;
      break;
    }
  }
  return 0;
}
