#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int mask = 0, len = 0;
    while (n) {
      if (n % 10 == 7) mask += 1 << len;
      n /= 10;
      ++len;
    }
    cout << mask + (1 << len) - 1 << "\n";
  }
  return 0;
}
