#include <bits/stdc++.h>
using namespace std;
const int N = 3228;
const int MOD = 1000 * 1000 * 1000 + 7;
long long pw(long long a, int first) {
  if (!first) return 1;
  if (first % 2) return a * pw(a * a, first / 2);
  return pw(a * a, first / 2);
}
void solve() {
  string a;
  cin >> a;
  long long n = pw(2, a.size()) - 1;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == '7') n += pw(2, a.size() - i - 1);
  }
  cout << n << "\n";
}
int main() {
  double tt = clock();
  cout.tie(nullptr);
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << setprecision(20);
  cout << fixed;
  solve();
  return 0;
}
