#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l = 0, count = 0;
  int array[2222];
  cin >> n >> k;
  for (int j = 0; j < n; j++) cin >> array[j];
  for (int j = 0; j < n; j++) {
    for (int s = 0; s < k; s++) {
      array[j]++;
    }
    if (array[j] <= 5) count++;
  }
  cout << count / 3;
  return 0;
}
