#include <bits/stdc++.h>
using namespace std;
int main() {
  int result = 0;
  int twos_power = 1, digit_contribution;
  int n;
  cin >> n;
  while (n) {
    int last = n % 10;
    digit_contribution = (last == 7) ? twos_power : 0;
    n /= 10;
    result += twos_power;
    result += digit_contribution;
    twos_power *= 2;
  }
  cout << result;
  return 0;
}
