#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string second;
  cin >> second;
  int l = second.size();
  for (int i = 0; i < l; i++) {
    if (second[i] == '4') {
      v.push_back(0);
    } else {
      v.push_back(1);
    }
  }
  int x = 0, y = v.size() - 1;
  for (unsigned int i = 0; i < v.size(); i++) {
    x += (1 << y) * v[i];
    y--;
  }
  int ans = 0;
  l--;
  ans = 2 * ((1 << l) - 1);
  ans += x + 1;
  cout << ans;
}
