#include <bits/stdc++.h>
using namespace std;
int num, n, ans;
int ada;
int main() {
  cin >> n;
  string s = to_string(n);
  int c = s.length();
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '7')
      ada = pow(2, abs(c) - i) + ada;
    else
      ada = pow(2, abs(c) - i - 1) + ada;
  }
  cout << ada << '\n';
  return 0;
}
