#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int sum = 0;
  int digit = 0;
  vector<int> v;
  while (n != 0) {
    digit++;
    v.push_back(n % 10);
    n = n / 10;
  }
  for (int i = 1; i < digit; i++) sum += pow(2, digit - i);
  for (int i = 0; i < digit - 1; i++) {
    if (v[digit - 1 - i] == 7) sum += pow(2, digit - i - 1);
  }
  if (v[0] == 7)
    sum += 2;
  else
    sum += 1;
  cout << sum;
}
