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