#include <bits/stdc++.h>
using namespace std;
vector<string> LuckyNum;
void calculateNums() {
  int K;
  LuckyNum.push_back("0");
  LuckyNum.push_back("4");
  LuckyNum.push_back("7");
  int start = 1;
  for (int i = (int)(2); i <= (int)(9); i++) {
    K = LuckyNum.size();
    for (int j = (int)(start); j <= (int)(K - 1); j++) {
      LuckyNum.push_back(LuckyNum[j] + "4");
      LuckyNum.push_back(LuckyNum[j] + "7");
    }
    start = K;
  }
}
int main() {
  calculateNums();
  string S;
  cin >> S;
  cout << find(LuckyNum.begin(), LuckyNum.end(), S) - LuckyNum.begin();
  return 0;
}
