#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[11];
  cin >> a;
  int n = strlen(a);
  int ans = 0, b = 0, j = 0;
  ans = pow(2, n) - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == '7') {
      b += pow(2, j);
    }
    j++;
  }
  cout << ans + b;
}
