#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
long long int MOD = 998244353;
long long int NUM = 1e9 + 7;
void solve() {
  int n, k;
  cin >> n >> k;
  int count = 0, tmp;
  for (long long int i = 0; i < n; i++) {
    cin >> tmp;
    if (tmp <= (5 - k)) count++;
  }
  cout << count / 3 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
