#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m, buc[N], f[N][3][3];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) buc[read()]++;
  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 (buc[i] - l - j - k >= 0)
            f[i][j][k] =
                max(f[i - 1][l][j] + k + (buc[i] - l - j - k) / 3, f[i][j][k]);
  printf("%d", f[m][0][0]);
}
