#include <bits/stdc++.h>
using namespace std;
bool check_753(int n) {
  bool n3 = false, n5 = false, n7 = false;
  while (n) {
    int num = n % 10;
    if (num != 3 && num != 5 && num != 7) return false;
    if (num == 3) n3 = true;
    if (num == 5) n5 = true;
    if (num == 7) n7 = true;
    n /= 10;
  }
  if (n3 && n5 && n7) return true;
  return false;
}
int find_753(int n) {
  int count = 0;
  if (n < 357) return 0;
  for (int i = 357; i <= n; i += 2) {
    if (check_753(i)) {
      count++;
    }
  }
  return count;
}
int main() {
  int n;
  cin >> n;
  cout << find_753(n) << endl;
  return 0;
}
