#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[2005];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int sum = 0, con = 0;
  for (int j = 0; j < n; j++) {
    if (a[j] + m <= 5)
      sum++;
    else
      break;
    if (sum % 3 == 0) con++;
  }
  printf("%d\n", con);
  return 0;
}
