#include <bits/stdc++.h>
using namespace std;
inline void rdl(int &x) {
  x = 0;
  bool check = false;
  register int c;
  do {
    c = getchar();
    if (c == '-') check = true;
  } while (c < 48 || c > 57);
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (check) x = -x;
}
inline void rd(int &x) {
  x = 0;
  bool check = false;
  register int c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
inline void pd(int x) {
  char c[11];
  bool check = false;
  int k = -1;
  if (x < 0) check = true, x = -x;
  do {
    c[++k] = x % 10 + 48;
    x /= 10;
  } while (x);
  if (check) c[++k] = '-';
  while (k >= 0) putchar(c[k--]);
  putchar('\n');
}
inline void pdl(long long int x) {
  char c[21];
  bool check = false;
  int k = -1;
  if (x < 0) check = true, x = -x;
  do {
    c[++k] = x % 10 + 48;
    x /= 10;
  } while (x);
  if (check) c[++k] = '-';
  while (k >= 0) putchar(c[k--]);
  putchar('\n');
}
bool cmp(int a, int b) { return a > b; }
int main() {
  char c[20];
  scanf("%s", c);
  int i, j, k, l, ans = 0;
  l = strlen(c);
  for (i = 0; i < l; i++) {
    if (c[i] == '4') {
      ans += pow(2, l - i - 1);
    } else {
      ans += pow(2, l - i);
    }
  }
  pd(ans);
}
