#include <bits/stdc++.h>
using namespace std;
const int N = 1E6 + 7;
int n, m, sum[N], f[N][3][3];
void read(int &x) {
  char c = getchar();
  x = 0;
  while (c < '0' || c > '9') c = getchar();
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + (c ^ '0');
}
void maxx(int &x, int y) { y > x && (x = y); }
int main() {
  read(n), read(m), memset(sum, 0, sizeof sum);
  for (int i = 1, x; i <= n; ++i) read(x), ++sum[x];
  memset(f, -0x3f, sizeof f), 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 l = 0; l < 3; ++l)
          if (sum[i] >= j + k + l)
            maxx(f[i][k][l], f[i - 1][j][k] + (sum[i] - j - k - l) / 3 + l);
  printf("%d\n", f[m][0][0]);
  return 0;
}
