#include <bits/stdc++.h>
template <typename T>
T Abs(T a) {
  return (a < 0 ? -a : a);
}
template <typename T>
T MAX(T a, T b) {
  return (a > b ? a : b);
}
template <typename T>
T MIN(T a, T b) {
  return (a < b ? a : b);
}
template <typename T>
T GCD(T a, T b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
template <typename T>
inline void read(T &x) {
  T f = 1;
  char c;
  x = 0;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
using fl = float;
using db = double;
using ll = long long;
using ull = unsigned long long;
const int mx = 1000005;
const int inf = 99999999;
const int intlim = 2147483648;
const db PI = acos(-1);
using namespace std;
int main() {
  string str;
  cin >> str;
  int c = 0;
  queue<string> q;
  if (str == "4")
    c = 1;
  else if (str == "7")
    c = 2;
  else {
    c = 2;
    q.push("4");
    q.push("7");
    while (1) {
      string s = q.front();
      q.pop();
      c++;
      if (s + "4" == str) break;
      q.push(s + "4");
      c++;
      if (s + "7" == str) break;
      q.push(s + "7");
    }
  }
  cout << c << "\n";
  return 0;
}
