#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int N, M;
  cin >> N >> M;
  vector<int> A(M + 2);
  int i, j, k, l;
  for (i = 0; i < N; i++) {
    int Temp;
    cin >> Temp;
    A[(Temp - 1)]++;
  }
  vector<vector<vector<int> > > Map(
      (M + 1), vector<vector<int> >(3, vector<int>(3, -1)));
  Map[0][0][0] = 0;
  int Result = 0;
  for (i = 0; i < M; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 3; k++) {
        if (Map[i][j][k] >= 0) {
          int T =
              min((A[i] - j - k), min((A[(i + 1)] - k), min(A[(i + 2)], 2)));
          for (l = 0; l <= T; l++) {
            Map[(i + 1)][k][l] =
                max(Map[(i + 1)][k][l],
                    ((Map[i][j][k] + l) + (A[i] - j - k - l) / 3));
            Result = max(Result, Map[(i + 1)][k][l]);
          }
        }
      }
    }
  }
  cout << Result << endl;
  return 0;
}
