#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> tiles(m, 0);
  for (int i = 0; i < n; i++) {
    int cur;
    cin >> cur;
    tiles[cur - 1]++;
  }
  vector<int> dprow(3, 0);
  vector<vector<int> > dpgrid(5, dprow);
  vector<vector<vector<int> > > dp(m, dpgrid);
  for (int dx = 0; dx <= min(4, tiles[m - 1]); dx++) {
    dp[m - 1][dx][0] = (tiles[m - 1] - dx) / 3;
  }
  for (int dx = 0; dx <= min(4, tiles[m - 2]); dx++) {
    for (int dy = 0; dy <= min(2, tiles[m - 1]); dy++) {
      dp[m - 2][dx][dy] = (tiles[m - 2] - dx) / 3 + (tiles[m - 1] - dy) / 3;
    }
  }
  for (int i = m - 3; i >= 0; i--) {
    for (int dx = 0; dx <= min(4, tiles[i]); dx++) {
      for (int dy = 0; dy <= min(2, tiles[i + 1]); dy++) {
        int z = tiles[i + 2];
        int x = tiles[i] - dx;
        int y = tiles[i + 1] - dy;
        dp[i][dx][dy] = max(dp[i][dx][dy], x / 3 + dp[i + 1][dy][0]);
        if (x > 0 && y > 0 && z > 0) {
          dp[i][dx][dy] =
              max(dp[i][dx][dy], (x - 1) / 3 + 1 + dp[i + 1][dy + 1][1]);
        }
        if (x > 1 && y > 1 && z > 1) {
          dp[i][dx][dy] =
              max(dp[i][dx][dy], (x - 2) / 3 + 2 + dp[i + 1][dy + 2][2]);
        }
      }
    }
  }
  cout << dp[0][0][0] << endl;
  return 0;
}
