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