#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long ind = pow(2, (int)s.size()) - 2;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '7') ind += pow(2, s.size() - 1 - i);
  }
  cout << ind + 1;
  return 0;
}
