#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  vector<int> lucky;
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j < (1 << i); j++) {
      int num = 0;
      for (int k = 0; k < i; k++) {
        if (j & (1 << k))
          num = num * 10 + 7;
        else
          num = num * 10 + 4;
      }
      lucky.push_back(num);
    }
  }
  sort(lucky.begin(), lucky.end());
  int n;
  cin >> n;
  for (int i = 0; i < lucky.size(); i++) {
    if (lucky[i] == n) {
      cout << i + 1;
      break;
    }
  }
  return 0;
}
