#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  queue<int> q;
  q.push(4);
  q.push(7);
  int k = 0;
  while (!q.empty()) {
    k++;
    int p = q.front();
    q.pop();
    if (p == n) break;
    q.push(p * 10 + 4);
    q.push(p * 10 + 7);
  }
  cout << k << '\n';
}
int main() {
  solve();
  return 0;
}
