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