#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  cin >> input;
  int Length = input.length();
  int sum = pow(2, Length) - 2;
  for (int i = 0; i < Length; i++) {
    char c = input[i];
    if (c == '7') {
      sum = sum + pow(2, Length - (i + 1));
    }
  }
  cout << sum + 1;
  return 0;
}
