#include <bits/stdc++.h>
using namespace std;
struct lucky_number {
  vector<char> digits;
  lucky_number() { digits.push_back(4); }
  void increment() {
    for (int i = 0; i < digits.size(); ++i) {
      if (digits[i] == 4) {
        digits[i] = 7;
        return;
      }
      digits[i] = 4;
    }
    digits.push_back(4);
  }
  int representation() {
    int res = 0;
    for (int i = digits.size() - 1; i >= 0; --i) {
      res = res * 10 + digits[i];
    }
    return res;
  }
};
int main() {
  lucky_number a;
  int n;
  cin >> n;
  int i = 1;
  while (a.representation() != n) {
    ++i;
    a.increment();
  }
  cout << i << endl;
  return 0;
}
