#include <bits/stdc++.h>
using namespace std;
char n[11];
int ans = 0;
int pow(int a, int n) {
  int cnt = 1;
  for (int i = 0; i < n; ++i) {
    cnt *= a;
  }
  return cnt;
}
void find() {
  int mul = 2;
  while (log2(mul) < strlen(n)) {
    ans += mul;
    mul *= 2;
  }
  for (int i = 0; n[i]; ++i) {
    if (n[i] == '7') {
      ans += mul / 2;
    }
    mul /= 2;
  }
}
int main() {
  scanf("%s", &n);
  find();
  printf("%d", ans + 1);
  return 0;
}
