#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream& operator<<(std::ostream& str, const std::vector<T>& v) {
  str << "[";
  for (auto n : v) str << n << ", ";
  str << "]";
  return str;
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& str, const std::unordered_map<K, V>& m) {
  str << "[";
  for (auto n : m) str << n.first << " => " << n.second << ", ";
  str << "]";
  return str;
}
void gen(int i, string c, vector<string>& r) {
  if (i == 0) {
    r.push_back(c);
    return;
  }
  gen(i - 1, c + "4", r);
  gen(i - 1, c + "7", r);
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int input;
  cin >> input;
  std::vector<string> all_n;
  for (int i = 1; i <= 10; i++) {
    gen(i - 1, "4", all_n);
    gen(i - 1, "7", all_n);
  }
  stringstream ss;
  ss << input;
  string inp_string = ss.str();
  for (int i = 0; i < all_n.size(); i++) {
    if (all_n[i] == inp_string) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "all_n"
       << ": " << all_n << endl;
  return 0;
}
