#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int dp[N][5][5], cnt[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  for (int i = m; i >= 1; i--) {
    for (int j = 0; j < 5; j++)
      for (int k = 0; k < 3; k++)
        for (int l = 0; l < 3; l++)
          if (min({cnt[i] - j, cnt[i + 1] - k, cnt[i + 2]}) >= l)
            dp[i][j][k] = max(dp[i][j][k],
                              l + (int)floor((double)((cnt[i] - j - l) / 3)) +
                                  dp[i + 1][k + l][l]);
  }
  cout << dp[1][0][0];
}
