#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> abc(n);
  for (int i = 0; i < n; ++i) cin >> abc[i];
  sort(abc.begin(), abc.end());
  int count = 0;
  for (int i = 0; i < n - 2; i += 3) {
    if (5 - abc[i] >= k && 5 - abc[i + 1] >= k && 5 - abc[i + 2] >= k)
      ++count;
    else
      break;
  }
  cout << count;
}
