#include <bits/stdc++.h>
using namespace std;
long long int arr[1500];
int main() {
  long long int num;
  cin >> num;
  memset(arr, 0, sizeof(arr));
  arr[1] = 4;
  arr[2] = 7;
  int k = 3;
  int current1 = 1;
  int current2 = 1;
  int range = 2;
  for (int i = 2; i <= 9; i++) {
    for (int j = 1; j <= range; j++) {
      arr[k] = arr[current1] * 10 + 4;
      current1++;
      k++;
    }
    for (int l = 1; l <= range; l++) {
      arr[k] = arr[current2] * 10 + 7;
      current2++;
      k++;
    }
    range = range * 2;
  }
  sort(arr + 1, arr + 1023);
  int z;
  for (z = 1; z <= 1024; z++) {
    if (arr[z] == num) break;
  }
  cout << z << endl;
  return 0;
}
