#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
const int N = 1000000 + 1;
int cnt[N];
int cache[N][4][3];
int n, m;
int solve(int idx, int t1, int t2) {
  if (cnt[idx] - t1 - t2 < 0) return -1e9;
  if (idx == m + 1) return 0;
  int &ans = cache[idx][t1][t2];
  if (ans != -1) return ans;
  int f = cnt[idx] - t1 - t2;
  ans = -1e9;
  for (int i = 0; i <= min(2, f); i++) {
    ans = max(ans, solve(idx + 1, t2, i) + i + (f - i) / 3);
  }
  return ans;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(cache, -1, sizeof(cache));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  cout << solve(1, 0, 0) << endl;
  return 0;
}
