#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  int f;
  char c;
  for (f = 1, c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
  x *= f;
}
template <typename T>
inline void write(T x) {
  static char q[64];
  int cnt = 0;
  if (!x) putchar('0');
  if (x < 0) putchar('-'), x = -x;
  while (x) q[cnt++] = x % 10 + '0', x /= 10;
  while (cnt--) putchar(q[cnt]);
}
const int maxn = 1000006;
int sum[maxn], dp[maxn][3][3];
int main() {
  int n, m;
  read(n), read(m);
  for (int i = 1, x; i <= n; ++i) read(x), ++sum[x];
  memset(dp, -0x3f, sizeof dp);
  dp[0][0][0] = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < 3 && j <= sum[i + 1]; ++j) {
      for (int k = 0; k < 3 && j + k <= sum[i + 1]; ++k) {
        for (int l = 0; l < 3 && j + k + l <= sum[i + 1]; ++l) {
          dp[i + 1][k][l] = max(dp[i + 1][k][l],
                                dp[i][j][k] + j + (sum[i + 1] - j - k - l) / 3);
        }
      }
    }
  }
  write(dp[m][0][0]), putchar('\n');
  return 0;
}
