#include <bits/stdc++.h>
int main() {
  int n, k, a[3000], swap = 0, count = 0, m = 0, sum = 0, sum1 = 0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (a[j] > a[j + 1]) {
        swap = a[j];
        a[j] = a[j + 1];
        a[j + 1] = swap;
      }
    }
  }
  m = 0;
  n = n / 3;
  while (sum1 < n) {
    a[m] = 5 - a[m];
    a[m + 1] = 5 - a[m + 1];
    a[m + 2] = 5 - a[m + 2];
    if (a[m] >= k && a[m + 1] >= k && a[m + 2] >= k) {
      count++;
      m = m + 3;
    } else {
      break;
    }
    sum1++;
  }
  printf("%d", count);
}
