#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m, x, ans, a[N], f[N][3][3];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[x]++;
  }
  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 (j + k + l > a[i]) continue;
          f[i][k][l] =
              max(f[i][k][l], f[i - 1][j][k] + (a[i] - j - k - l) / 3 + l);
        }
  printf("%d", f[m][0][0]);
  return 0;
}
