#include <bits/stdc++.h>
using namespace std;
inline string get_string() {
  char ch[1000000];
  scanf("%s", ch);
  return ch;
}
void ans(int a) {
  cout << a << "\n";
  exit(0);
}
int main() {
  long long n;
  cin >> n;
  if (n < 3)
    ans(0);
  else if (n == 4)
    ans(1);
  long a = 0;
  string number = "4";
  while (atoi(number.c_str()) < n) {
    a++;
    int g;
    for (g = (int)number.length() - 1; g >= 0; g--) {
      if (number[g] == '4') {
        for (int l = g + 1; l < number.length(); l++) number[l] = '4';
        number[g] = '7';
        break;
      }
      if (!g) {
        int theLength = number.length();
        number = "4";
        for (int i = 0; i < theLength; i++) number = number + "4";
      }
    }
  }
  ans(a + 1);
}
