#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int cntr = 1, n, x, ans = 0;
  cin >> n;
  while (n) {
    x = n % 10;
    n /= 10;
    if (x == 4)
      ans += (1 * cntr);
    else if (x == 7)
      ans += (2 * cntr);
    cntr *= 2;
  }
  cout << ans << endl;
}
