#include <bits/stdc++.h>
using namespace std;
int freq[1000010], memo[1000010][3][3], dp[1000010][3][3], n, m;
int f(int i, int aa, int a) {
  if (i > m) {
    if (aa + a > 0)
      return -1000010;
    else
      return 0;
  }
  if (memo[i][aa][a]) return dp[i][aa][a];
  memo[i][aa][a] = 1;
  if (aa + a > freq[i]) return dp[i][aa][a] = -1000010;
  int aux = freq[i] - (aa + a), ans = -1000010;
  ans = max(ans, f(i + 1, a, 0) + (aux / 3));
  if (aux > 0) ans = max(ans, f(i + 1, a, 1) + 1 + ((aux - 1) / 3));
  if (aux > 1) ans = max(ans, f(i + 1, a, 2) + 2 + ((aux - 2) / 3));
  return dp[i][aa][a] = ans;
}
int main() {
  int i, aux;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &aux), freq[aux]++;
  printf("%d\n", f(0, 0, 0));
}
