#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxm = 1100000;
int dp[2][3][3];
int a[maxm];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); ++i) {
    int x;
    cin >> x;
    ++a[x];
  }
  for (int i = 0; i < (int)(3); ++i)
    for (int j = 0; j < (int)(3); ++j) dp[0][i][j] = -1e9;
  dp[0][0][0] = 0;
  for (int i = 1; i <= (int)(m + 10); ++i) {
    for (int i = 0; i < (int)(3); ++i)
      for (int j = 0; j < (int)(3); ++j) dp[1][i][j] = -1e9;
    for (int p1 = 0; p1 < (int)(3); ++p1)
      for (int p2 = 0; p2 < (int)(3); ++p2) {
        int left = a[i] - p1 - p2;
        for (int p3 = 0; p3 < (int)(3); ++p3) {
          if (left - p3 < 0) continue;
          uax(dp[1][p2][p3], dp[0][p1][p2] + p3 + (left - p3) / 3);
        }
      }
    for (int i = 0; i < (int)(3); ++i)
      for (int j = 0; j < (int)(3); ++j) dp[0][i][j] = dp[1][i][j];
  }
  cout << dp[0][0][0] << '\n';
  return 0;
}
