#include <bits/stdc++.h>
using namespace std;
int a[10005];
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  k = 5 - k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int s = 0;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n - 2; i += 3) {
    if (a[i] <= k && a[i + 1] <= k && a[i + 2] <= k) {
      s++;
      a[i] = 5;
      a[i + 1] = 5;
      a[i + 2] = 5;
    }
  }
  cout << s;
}
