#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> ma;
void sieve() {
  ma[1] = 1;
  for (int i = 3; i * i <= 1000010; i = i + 2) {
    if (ma[i] == 0) {
      for (int j = i * i; j <= 1000010; j = j + (2 * i)) {
        ma[j] = 1;
      }
    }
  }
}
int main() {
  long long int i, j, k, a, b, c, n, t, m, d, r, g, y, f;
  vector<long long int> s, ss, vv;
  vector<pair<pair<long long int, long long int>, long long int> > v;
  map<long long int, long long int> it, ki;
  map<char, long long int> ga, ha;
  string st, et, mt;
  cin >> n >> k;
  c = 0;
  d = 0;
  for (i = 1; i <= n; i++) {
    cin >> a;
    if ((5 - a) >= k) {
      c++;
    }
  }
  c = c / 3;
  cout << c << endl;
}
