#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  string n;
  cin >> n;
  long long int l = n.length();
  long long int sum = 0;
  sum = (1 << l) - 2;
  for (long long int i = l - 1, j = 0; i >= 0; i--, j++) {
    if (n[i] == '7') sum += 1 << j;
  }
  cout << sum + 1;
}
