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