#include <bits/stdc++.h>
using namespace std;
const int N = 1.1e6;
int ans;
int n, m;
vector<int> F;
int S[N][7][7];
int s(int i, int a, int b) {
  if (i == m) return (F[i] - a) / 3;
  if (i + 1 == m) return (F[i] - a) / 3 + (F[i + 1] - b) / 3;
  int loc = S[i + 1][b][0];
  for (int j = 0; j < 3; j++)
    if (a + j <= min(6, F[i]) && b + j <= min(6, F[i + 1]) &&
        0 + j <= min(6, F[i + 2]))
      loc = max(loc, j + ((F[i] - (a + j)) / 3) + S[i + 1][b + j][j]);
  return loc;
}
int main() {
  scanf(" %d%d", &n, &m);
  F = vector<int>(m + 1);
  for (int i = 0; i < n; i++) {
    int a;
    scanf(" %d", &a);
    F[a]++;
  }
  for (int i = m; i + 1; i--)
    for (int a = 0; a < 7; a++)
      for (int b = 0; b < 7; b++) S[i][a][b] = s(i, a, b);
  printf("%d\n", ans + S[0][0][0]);
}
