#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;
const int N = 1000228;
int a[N];
int f[4][4];
int g[4][4];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++a[x];
  }
  for (int i = 1; i <= m + 5; ++i) {
    memcpy(g, f, sizeof(g));
    memset(f, 0, sizeof(f));
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        for (int l = 0; l < 3; ++l) {
          int cur = a[i] - j - k - l;
          if (cur >= 0) {
            int& ng = f[k][l];
            ng = max(ng, g[j][k] + cur / 3 + l);
          }
        }
      }
    }
  }
  cout << f[0][0] << "\n";
}
