#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ans = 0, temp1 = 1, temp2 = 2, temp;
  cin >> n;
  while (n > 0) {
    temp = n % 10;
    if (temp == 4)
      ans += temp1;
    else
      ans += temp2;
    temp1 *= 2;
    temp2 *= 2;
    n /= 10;
  }
  cout << ans << endl;
  return 0;
}
