#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int n) {
  if (a == n || n == 0 || a == 0) return a;
  if (a > n)
    return gcd(a - n, n);
  else
    return gcd(a, n - a);
}
bool perfect(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n = n / 10;
  }
  if (sum == 10)
    return true;
  else
    return false;
}
int binarySerch(int a[], int first, int end, int target) {
  while (first <= end) {
    int k = (first + end) / 2;
    if (a[k] == target) {
      return k;
    }
    if (a[k] < target) {
      end = k - 1;
    } else {
      first = k + 1;
    }
  }
  return -1;
}
int serch(int a[], int end, int target) {
  int k = 1;
  for (int i = end / 2; i >= 1; i /= 2) {
    while (k + i <= end && a[k] <= target) k += i;
  }
  if (a[k] == target) {
    return k;
  } else {
    return -1;
  }
}
bool prime(int n) {
  if (n < 2) return false;
  for (int x = 2; x * x <= n; x++) {
    if (n % x == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int len = 0;
  int ans = 0;
  while (n) {
    if (n % 10 == 7) ans += (1 << len);
    n /= 10;
    len++;
  }
  for (int i = 1; i < len; i++) ans += (1 << i);
  cout << ans + 1 << endl;
  return 0;
}
