#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int temp = n, no_of_digits = 0, count = 0, add = 0;
  while (temp != 0) {
    if (temp % 10 == 7) {
      if (no_of_digits >= 0) add += pow(2, no_of_digits);
      count++;
    }
    temp = temp / 10;
    no_of_digits++;
  }
  add += (1 << no_of_digits) - 2;
  cout << add + 1;
  return 0;
}
