#include <bits/stdc++.h>
int main() {
  int n, k, a[2005], i, j, temp, count = 0, x = 0, y = 0, z = 0;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
  for (i = 0; i < n; i = i + 3) {
    x = 0;
    y = 0;
    z = 0;
    if (i + 2 < n) {
      x += a[i] + k;
      y += a[i + 1] + k;
      z += a[i + 2] + k;
    } else
      break;
    if (x <= 5 && y <= 5 && z <= 5)
      count++;
    else
      break;
  }
  printf("%d", count);
  return 0;
}
