#include <bits/stdc++.h>
using namespace std;
int power2(int exp) {
  if (exp == 0)
    return 1;
  else
    return 2 << exp - 1;
}
int main() {
  string s;
  cin >> s;
  vector<int> str;
  for (int i = 0; i < s.size(); i++) {
    int a = s[i] - '0';
    str.push_back(a);
  }
  reverse(str.begin(), str.end());
  int t = 0;
  for (int i = 0; i < s.size(); i++) {
    if (str[i] == 4)
      t += power2(i);
    else
      t += 2 * power2(i);
  }
  cout << t;
}
