#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T gcd(T a, T b) {
  while (b != 0) swap(b, a %= b);
  return a;
}
int main() {
  string s;
  cin >> s;
  int n = (int)s.length();
  long long ans = (1 << n) - 2;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '7') ans += (1 << (n - i - 1));
  }
  cout << ans + 1;
}
