#include <bits/stdc++.h>
using namespace std;
vector<string> numbers;
unsigned n = 2;
unsigned k = 5;
int taken[100];
void print(unsigned i) {
  unsigned l;
  string str = "";
  for (l = 0; l <= i - 1; l++) str += (taken[l] + 1) + '0';
  numbers.push_back(str);
}
void variate(unsigned i) {
  unsigned j;
  if (i >= k) {
    print(i);
    return;
  }
  for (j = 0; j < n; j++) {
    taken[i] = j;
    variate(i + 1);
  }
}
int main(void) {
  for (unsigned i = 1; i < 11; i++) {
    k = i;
    variate(0);
  }
  string input;
  cin >> input;
  for (int i = 0; i < input.size(); i++) {
    if (input[i] == '4')
      input[i] = '1';
    else
      input[i] = '2';
  }
  for (int i = 0; i < numbers.size(); i++) {
    if (numbers[i] == input) cout << i + 1 << endl;
  }
  return 0;
}
