#include <bits/stdc++.h>
using namespace std;
int ar1[10];
int main() {
  int a, b, c = 1, d, s = 0, r, t, h, j, i, k, l, n, m;
  cin >> n >> k;
  int ar[n + 10];
  for (i = 0; i < n; i++) {
    cin >> a;
    ar1[a]++;
  }
  for (i = 0; i < 6 - k; i++) {
    s = s + ar1[i];
  }
  s = s / 3;
  cout << s << endl;
  return 0;
}
