#include <bits/stdc++.h>
using namespace std;
int magicOrder(string s) {
  if (s == "4") return 1;
  if (s == "7")
    return 2;
  else if (s[0] == '4') {
    return 2 * (pow(2, s.length() - 1) - 1) +
           magicOrder(s.substr(1, s.length() - 1)) + 1 -
           magicOrder(string(s.length() - 1, '4'));
  } else
    return 2 * (pow(2, s.length() - 1) - 1) + pow(2, s.length() - 1) +
           magicOrder(s.substr(1, s.length() - 1)) + 1 -
           magicOrder(string(s.length() - 1, '4'));
}
int main() {
  string n;
  cin >> n;
  cout << magicOrder(n) << endl;
}
