#include <bits/stdc++.h>
using namespace std;
int main() {
  char no[20];
  cin >> no;
  int len = strlen(no);
  int ans = (1 << len) - 2;
  for (int i = (len - 1), pos = 0; i >= 0; i--, pos++) {
    if (no[i] == '7') ans += (1 << pos);
  }
  cout << ans + 1 << endl;
  return 0;
}
