#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, arry[50000], beg, end, cnt = 3, num;
  arry[0] = -4444;
  arry[1] = 4;
  arry[2] = 7;
  int k = 1, i;
  beg = 1, end = 2;
  while (k != 11) {
    for (i = beg; i <= end; i++) {
      arry[cnt] = arry[i] * 10 + 4;
      cnt++;
      arry[cnt] = arry[i] * 10 + 7;
      cnt++;
    }
    k++;
    beg = end + 1;
    end = pow(2, k) + end;
  }
  cin >> num;
  for (i = 0; i < 4095; i++) {
    if (arry[i] == num) {
      cout << i << endl;
      break;
    }
  }
  return (0);
}
