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