#include <bits/stdc++.h>
using namespace std;
bool Check753(int32_t x) {
  int32_t digit = static_cast<int32_t>(log10(x)) + 1;
  bool flag3 = false, flag5 = false, flag7 = false;
  int32_t cnt = 0;
  for (size_t i = 0, end = static_cast<size_t>(digit); i < end; ++i) {
    int32_t n = x % 10;
    x = x / 10;
    if (n == 3) {
      flag3 = true;
      ++cnt;
    } else if (n == 5) {
      flag5 = true;
      ++cnt;
    } else if (n == 7) {
      flag7 = true;
      ++cnt;
    }
  }
  return ((digit == cnt) && flag3 && flag5 && flag7);
}
int main() {
  int32_t n = 0;
  cin >> n;
  int32_t ans = 0;
  for (size_t i = 1, end = static_cast<size_t>(n); i <= n; ++i) {
    if (Check753(i)) {
      ++ans;
    }
  }
  cout << ans << endl;
  return (0);
}
