#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long minf = -(1e18);
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  string str;
  cin >> str;
  int l = str.length();
  long long sum = 0;
  int num = 0;
  int j = 0;
  for (int i = str.length() - 1; i >= 0; i--) {
    if (str[i] == '4')
      num += (0 * pow(2, j));
    else
      num += (1 * pow(2, j));
    j++;
  }
  for (int i = l - 1; i >= 1; i--) {
    sum += pow(2, i);
  }
  cout << sum + num + 1;
  return 0;
}
