#include <bits/stdc++.h>
using namespace std;
const int maxn = 20 + 10;
long long n;
long long po[maxn];
long long po_[maxn];
long long po10[maxn];
long long ans = 0;
long long dfs(long long n, long long weishu);
long long solve(long long x) {
  long long cnt = 0;
  long long tmp = x;
  while (tmp) {
    tmp /= 10;
    cnt++;
  }
  return dfs(x, cnt) + po[cnt - 1];
}
long long dfs(long long x, long long weishu) {
  if (x == 4) return 1;
  if (x == 7) return 2;
  if (x / po10[weishu - 1] == 4) {
    return dfs(x % (po10[weishu - 1]), weishu - 1);
  } else {
    return dfs(x % (po10[weishu - 1]), weishu - 1) + po_[weishu - 1];
  }
}
int main() {
  po[0] = 1;
  po10[0] = 1;
  po_[0] = 1;
  for (int i = 1; i < maxn; i++) {
    po[i] = po[i - 1] * 2;
    po_[i] = po_[i - 1] * 2;
  }
  for (int i = 1; i < 18; i++) {
    po10[i] = po10[i - 1] * 10;
  }
  for (int i = 2; i < maxn; i++) {
    po[i] += po[i - 1];
  }
  po[0] = 0;
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}
