#include <bits/stdc++.h>
using namespace std;
const int MaxN(1000003);
int a[MaxN], F[MaxN][3][3];
template <class I>
inline void chmax(I &x, I y) {
  x < y ? x = y : x;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), ++a[x];
  for (int i = 0; i <= m; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) F[i][j][k] = -1e9;
  F[0][0][0] = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        for (int t = 0; t < 3; t++)
          if (a[i] >= j + k + t)
            chmax(F[i][k][t], F[i - 1][j][k] + j + (a[i] - j - k - t) / 3);
  printf("%d\n", F[m][0][0]);
  return 0;
}
