#include <bits/stdc++.h>
bool is(int k) {
  bool is3, is5, is7;
  is3 = is5 = is7 = false;
  while (k) {
    int c = k % 10;
    if (c != 3 && c != 5 && c != 7) return false;
    if (c == 3) is3 = true;
    if (c == 5) is5 = true;
    if (c == 7) is7 = true;
    k /= 10;
  }
  if (is3 && is7 && is5)
    return true;
  else
    return false;
}
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 357; i <= n; i += 2) {
    if (is(i)) {
      cnt++;
    }
  }
  printf("%d", cnt);
}
