#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[100] = {0};
  for (int i = 0, b = 0; i < n; i++) {
    scanf("%d", &b);
    a[b]++;
  }
  int ans = 0;
  for (int i = 0; i <= (5 - m); i++) {
    ans += a[i];
  }
  printf("%d\n", ans / 3);
  return 0;
}
