#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c = 0, f = 0;
  cin >> n >> k;
  int y[n];
  for (int i = 0; i < n; i++) cin >> y[i];
  if (k == 5) {
    for (int i = 0; i < n; i++) {
      if (y[i] == 0) c++;
    }
    if (c >= 3) {
      if (c == 6)
        f = 2;
      else
        f = (int)(c / 3);
    }
  } else if (k == 4) {
    for (int i = 0; i < n; i++) {
      if (y[i] == 0 || y[i] == 1) c++;
    }
    if (c == 6)
      f = 2;
    else
      f = (int)(c / 3);
  } else if (k == 3) {
    for (int i = 0; i < n; i++) {
      if (y[i] == 0 || y[i] == 1 || y[i] == 2) c++;
    }
    if (c == 6)
      f = 2;
    else
      f = (int)(c / 3);
  } else if (k == 2) {
    for (int i = 0; i < n; i++) {
      if (y[i] == 0 || y[i] == 1 || y[i] == 2 || y[i] == 3) c++;
    }
    if (c == 6)
      f = 2;
    else
      f = (int)(c / 3);
  } else if (k == 1) {
    for (int i = 0; i < n; i++) {
      if (y[i] == 4 || y[i] == 0 || y[i] == 1 || y[i] == 2 || y[i] == 3) c++;
    }
    if (c == 6)
      f = 2;
    else
      f = (int)(c / 3);
  }
  cout << f;
  return 0;
}
