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