#include <bits/stdc++.h>
using namespace std;
int n, d, poz, lun;
int v[1000000];
int put = 10, bun = 1;
int main() {
  cin >> n;
  if (n == 4) {
    cout << 1 << endl;
    bun = 0;
  }
  if (n == 7) {
    cout << 2 << endl;
    bun = 0;
  }
  v[1] = 4;
  v[2] = 7;
  d = 3;
  poz = 3;
  lun = 2;
  while (d < 1000 && v[d - 1] <= 1000000000 && bun) {
    for (int i = poz - lun; i <= poz - 1; i++) {
      v[d] = 4 * put + v[i];
      if (v[d] == n) {
        cout << d << "\n";
        bun = 0;
      }
      d++;
    }
    for (int i = poz - lun; i <= poz - 1; i++) {
      v[d] = 7 * put + v[i];
      if (v[d] == n) {
        cout << d << "\n";
        bun = 0;
      }
      d++;
    }
    lun = lun * 2;
    poz = d;
    put = put * 10;
  }
  return 0;
}
