#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m, x, s[N], f[N][3][3];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); i++) scanf("%d", &x), s[x]++;
  memset(f, -1, sizeof(f));
  f[0][0][0] = 0;
  for (int i = (0); i <= (m - 1); i++)
    for (int j = (0); j <= (2); j++)
      for (int k = (0); k <= (2); k++)
        if (~f[i][j][k] && j + k <= s[i + 1])
          for (int l = (0); l <= (min(2, s[i + 1] - j - k)); l++)
            f[i + 1][k][l] = max(f[i + 1][k][l],
                                 f[i][j][k] + l + (s[i + 1] - j - k - l) / 3);
  printf("%d\n", f[m][0][0]);
  return 0;
}
