#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const double EPS = 1e-9;
string s = "000000000";
int n;
int ans = 0;
int not_zeros = 0;
bool gen(int index) {
  if (index == 9) {
    if (stoi(s) == n) {
      cout << ans << endl;
      return 1;
    } else {
      ans++;
      return 0;
    }
  } else {
    if (!not_zeros) {
      s[index] = '0';
      if (gen(index + 1)) {
        return 1;
      }
    }
    s[index] = '4';
    not_zeros++;
    if (gen(index + 1)) {
      return 1;
    }
    s[index] = '7';
    if (gen(index + 1)) {
      return 1;
    }
    s[index] = '0';
    not_zeros--;
    return 0;
  }
}
int main() {
  cin >> n;
  gen(0);
  return 0;
}
