#include <bits/stdc++.h>
int main() {
  std::string input;
  std::cin >> input;
  long long answer = 0;
  answer += 2 * (std::pow(2, input.size() - 1) - 1) + 1;
  for (std::size_t i = 0; i < input.size(); ++i) {
    if (input[i] == '7') {
      answer += std::pow(2, input.size() - 1 - i);
    }
  }
  std::cout << answer << std::endl;
}
