#include <bits/stdc++.h>
using namespace std;
int n, minn, m, i, j, ans = 0, maxx;
long long a[100000] = {0};
string s[110];
int main() {
  cin >> n;
  a[0] = 4;
  a[1] = 7;
  m = 0;
  i = 2;
  while (a[m] < 1000000000) {
    a[i] = a[m] * 10 + 4;
    i++;
    a[i] = a[m] * 10 + 7;
    i++;
    m++;
  }
  for (j = 0; j < i; ++j) {
    if (a[j] == n) {
      cout << j + 1;
      return 0;
    }
  }
  return 0;
}
