#include <bits/stdc++.h>
using namespace std;
int find_index(long long int n) {
  int digits = 0, binary_num = 0;
  while (n) {
    binary_num += (n % 10 == 7) * 1 << digits;
    digits++;
    n /= 10;
  }
  return (1 << digits) + binary_num - 1;
}
int main() {
  long long int n;
  int i, ans;
  scanf("%I64d", &n);
  ans = find_index(n);
  printf("%i", ans);
  return 0;
}
