#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int sum[N], dp[N][5][5];
inline int read() {
  int x = 0, f = 0, ch = getchar();
  while (!isdigit(ch)) {
    f |= ch == '-';
    ch = getchar();
  };
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  }
  return f ? -x : x;
}
int main() {
  int n, m;
  n = read();
  m = read();
  for (register int i = 1; i <= n; i++) sum[read()]++;
  for (register int i = 1; i <= m; i++)
    for (register int x = 0; x <= 2; x++)
      for (register int y = 0; y <= 2; y++)
        for (register int z = 0; z <= 2; z++) {
          if (x + y + z > sum[i]) continue;
          dp[i][x][y] =
              max(dp[i][x][y], dp[i - 1][z][x] + (sum[i] - x - y - z) / 3 + y);
        }
  printf("%d\n", dp[m][0][0]);
}
