#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265359;
const double EPS = 1e-6;
const long long INF = (1LL << 62);
const long long P = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long target = 5 - k;
  long long tmp;
  long long tot = 0;
  while (n--) {
    cin >> tmp;
    if (tmp <= target) tot++;
  }
  cout << tot / 3;
  return 0;
}
