#include <bits/stdc++.h>
using namespace std;
const int N = 2000004;
int pow(int a, int n) {
  if (n == 1) return a;
  return pow(a, n - 1) * a;
}
int main() {
  int n;
  scanf("%d", &n);
  int s = 0;
  int nn = n;
  int m = 0;
  while (nn) {
    if (nn % 10 == 7) m += (1 << s);
    s++;
    nn /= 10;
  }
  int ans = 0;
  for (int i = 1; i < s; i++) ans += pow(2, i);
  ans += (m + 1);
  printf("%d\n", ans);
  return 0;
}
