#include <bits/stdc++.h>
int main() {
  std::string A;
  std::cin >> A;
  int digit = A.size();
  int count = 0;
  std::vector<std::string> targetNumbers = {"3", "5", "7"};
  auto Add357 = [](std::vector<std::string>& src) {
    std::vector<std::string> temp;
    const std::string str357 = "357";
    for (auto&& str : src) {
      for (auto&& ch : str357) {
        temp.push_back(str + ch);
      }
    }
    src.insert(src.end(), temp.begin(), temp.end());
  };
  for (int i = 1; i < digit; i++) {
    Add357(targetNumbers);
  }
  int maxNumber = std::stoi(A);
  for (auto&& number : targetNumbers) {
    if (maxNumber < std::stoi(number)) {
      continue;
    }
    if (number.find_first_of('7') == std::string::npos) {
      continue;
    }
    if (number.find_first_of('5') == std::string::npos) {
      continue;
    }
    if (number.find_first_of('3') == std::string::npos) {
      continue;
    }
    count++;
  }
  std::cout << count << std::endl;
  return 0;
}
