#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int hash1 = 20041123;
const int hash2 = 20050208;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int n, m;
int a[1000005];
int cnt[1000005];
int dp[1000005][3][3];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    cnt[a[i]]++;
  }
  for (int i = 0; i <= m; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) dp[i][j][k] = -1e9;
  dp[0][0][0] = 0;
  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 <= cnt[i])
            dp[i][k][l] = max(dp[i][k][l],
                              dp[i - 1][j][k] + (cnt[i] - j - k - l) / 3 + j);
  }
  cout << dp[m][0][0];
  return 0;
}
