#include <bits/stdc++.h>
using namespace std;
int a[2111];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int m = n / 3, v = 3, sum = 0;
  for (int i = 1; i <= m; i++) {
    if (a[v] + k <= 5) {
      sum++;
    }
    v += 3;
  }
  cout << sum << endl;
  return 0;
}
