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