#include <bits/stdc++.h>
using namespace std;
bool h(string &s) {
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '4') return true;
  }
  return false;
}
int main() {
  string in, start{"4"};
  long long sum;
  cin >> in;
  if (in == "7")
    cout << 2 << endl;
  else if (in == "4")
    cout << 1 << endl;
  else {
    start = "44";
    sum = 3;
    while (in != start) {
      sum++;
      if (start[start.length() - 1] == '4') {
        start[start.length() - 1] = '7';
      } else if (h(start)) {
        for (int i = start.length() - 1; i > 0; --i) {
          if (start[i] == '7' && start[i - 1] == '4') {
            start[i - 1] = '7';
            for (int j = i; j < start.length(); ++j) start[j] = '4';
            break;
          }
        }
      } else {
        start += "4";
        for (int i = 0; i < start.length(); ++i) {
          if (start[i] != '4') start[i] = '4';
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
