#include <bits/stdc++.h>
using namespace std;
int main() {
  string num;
  cin >> num;
  int ans = 0;
  int power = 0;
  for (int i = 0; i < num.length(); i++) power += 1 << i;
  for (int i = 0; i < num.length(); i++) {
    if (num[i] == '7')
      ans = ans * 2 + 1;
    else
      ans = ans * 2;
  }
  printf("%d\n", power + ans);
  return 0;
}
