#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int n, m;
int cnt[N];
int dp[N][5][5];
int rec(int cur, int t1, int t2) {
  if (cur == m + 1) return 0;
  int& ctt = dp[cur][t1][t2];
  if (ctt != -1) return ctt;
  ctt = 0;
  for (int t3 = 0; t3 <= min({4, cnt[cur]}); ++t3) {
    for (int i = 0; i <= min({t1, t2, 2, cnt[cur] - t3}); ++i) {
      int take = (cnt[cur] - (i + t3)) / 3 + i;
      ctt = max(ctt, take + rec(cur + 1, t2 - i, t3));
    }
  }
  return ctt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    ++cnt[t];
  }
  int ans = rec(1, 0, 0);
  cout << ans << "\n";
}
