#include <bits/stdc++.h>
using namespace std;
queue<int> Q;
string r;
map<string, int> who;
int order;
void go(int p, int x) {
  if (x == p) {
    who[r] = ++order;
    return;
  }
  r[p] = '4';
  go(p + 1, x);
  r[p] = '7';
  go(p + 1, x);
}
void solve() {
  string s;
  cin >> s;
  for (int i = 1; i <= 9; i++) {
    r.resize(i);
    go(0, i);
  }
  cout << who[s];
}
int main() {
  solve();
  return 0;
}
