#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 20;
int n, m;
int h[maxn];
const int K = 7;
int dp[maxn][K][K];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  m++;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    h[x + 1]++;
  }
  for (int i = m; i >= 2; i--) {
    int h2 = h[i - 2], h1 = h[i - 1], h0 = h[i - 0], n1 = h[i + 1],
        n2 = h[i + 2];
    for (int a = 0; a <= min(h1, h2) && a < K; a++) {
      for (int b = 0; a + b <= min(h1, h0) && b < K; b++) {
        int tmp = 0;
        for (int c = 0; c < K && c <= h0 - a - b && c + b <= n1 && c <= n2;
             c++) {
          tmp = max(tmp, c + (h0 - a - b - c) / 3 + dp[i + 1][b][c]);
        }
        dp[i][a][b] = tmp;
      }
    }
  }
  cout << dp[2][0][0] << endl;
  return 0;
}
