#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int temp = n;
  int position = 1;
  int i = 0;
  while (temp != 0) {
    position += (temp % 10) / 5 * pow(2, i);
    temp /= 10;
    i++;
  }
  while (i > 1) {
    position += pow(2, i - 1);
    i--;
  }
  cout << position << endl;
  return 0;
}
