#include <bits/stdc++.h>
using namespace std;
bool judge(int t) {
  bool three = false;
  bool five = false;
  bool seven = false;
  bool other = true;
  int n;
  while (t > 0) {
    n = t % 10;
    t /= 10;
    if (n == 3)
      three = true;
    else if (n == 5)
      five = true;
    else if (n == 7)
      seven = true;
    else
      other = false;
  }
  return three && five && seven && other;
}
int main() {
  int t, i, c = 0, j, h, n;
  scanf("%d", &t);
  if (t < 357)
    printf("0");
  else {
    for (i = 357; i <= t; i += 2) {
      if (judge(i)) c++;
    }
    printf("%d", c);
  }
}
