#include <bits/stdc++.h>
using namespace std;
char c[15];
int main() {
  while (scanf("%s", &c) != EOF) {
    int sum = 0;
    int l = strlen(c);
    for (int i = 0; i < l; i++) {
      if (c[i] == '4')
        sum = sum * 2 + 1;
      else
        sum = sum * 2 + 2;
    }
    cout << sum << endl;
  }
  return 0;
}
