#include <bits/stdc++.h>
using namespace std;
inline void INP() {}
const long long inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
long long n, m, k, q;
string s;
vector<long long> adj[(long long)1e6 + 5];
long long dp[(long long)1e6 + 5][3][3][3], fr[(long long)1e6 + 5],
    a[(long long)1e6 + 5];
void go() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    ++fr[x];
  }
  dp[0][0][0][0] = 0;
  for (long long i = 1; i < m + 1; i++) {
    for (long long x = 0; x < 3; x++) {
      for (long long y = 0; y < 3; y++) {
        for (long long z = 0; z < 3; z++) {
          long long allSame = fr[i] - (x + y + z);
          if (allSame >= 0) {
            for (long long w = 0; w < 3; w++) {
              dp[i][x][y][z] =
                  max(dp[i][x][y][z], dp[i - 1][w][x][y] + z + allSame / 3);
            }
          }
        }
      }
    }
  }
  long long ans = -inf;
  for (long long w = 0; w < 3; w++) ans = max(ans, dp[m][w][0][0]);
  cout << ans << '\n';
}
int32_t main() {
  INP();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) go();
}
