#include <bits/stdc++.h>
using namespace std;
void plusplus(string &s) {
  int i = s.size() - 1;
  if (s[i] == '0') {
    s[i] = '1';
  } else {
    while (i >= 0 && s[i] == '1') {
      s[i] = '0';
      i--;
    }
    if (i >= 0) {
      s[i] = '1';
    }
  }
}
int main() {
  int n;
  cin >> n;
  int q = n, w = n;
  int cnt = 0;
  int answer = 0;
  while (q) {
    q /= 10;
    cnt++;
  }
  if (cnt != 0) {
    answer += pow(2, cnt) - 1;
  }
  string s = "";
  string ex = "";
  for (int i = 0; i < cnt; i++) {
    s += '0';
  }
  while (w) {
    if (w % 10 == 4) {
      ex += '0';
    } else {
      ex += '1';
    }
    w /= 10;
  }
  reverse(ex.begin(), ex.end());
  while (s != ex) {
    plusplus(s);
    answer++;
  }
  cout << answer << endl;
  return 0;
}
