#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, k;
  cin >> n >> k;
  int a[n], c = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n; i += 3) {
    if (a[i] <= 5 && a[i + 1] <= 5 && a[i + 2] <= 5) {
      if ((a[i] += k) <= 5 && (a[i + 1] += k) <= 5 && (a[i + 2] += k) <= 5) c++;
    }
  }
  cout << c;
}
