#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
const int N = 1e4 + 5;
int A[N], n, k, cnt, e;
void solve() {
  cnt = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", A + i);
  sort(A, A + n);
  e = n / 3;
  for (int i = 0; i < e; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) ok = ok && A[3 * i + j] + k <= 5;
    if (ok) cnt++;
  }
  printf("%d\n", cnt);
}
