#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = 0, k = 0;
  cin >> n >> k;
  int d = 5 - k;
  vector<int> arr;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  sort(arr.begin(), arr.end());
  int team = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] <= d) {
      team++;
    } else {
      break;
    }
  }
  cout << team / 3;
  return 0;
}
