#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0, k = 0;
  while (n != 0) {
    int s = n % 10;
    k += 1;
    if (s == 7) {
      sum += int(pow(2 * 1.0, (k - 1) * 1.0));
    }
    n /= 10;
  }
  int ans;
  ans = int(pow(2 * 1.0, k * 1.0)) - 1 + sum;
  cout << ans << endl;
}
