#include <bits/stdc++.h>
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
long long n, m, x, dp[1000008][3][3], col[1000008];
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i(1); i <= (n); ++i) scanf("%I64d", &x), col[x]++;
  memset(dp, -int(0x3f3f3f3f), sizeof(dp)), dp[0][0][0] = 0;
  for (int i(0); i <= (m); ++i) {
    for (int j(0); j <= (2); ++j) {
      for (int k(0); k <= (2); ++k) {
        if (dp[i][j][k] < 0) continue;
        long long now = col[i + 1] - j - k;
        for (int kk = 0; kk <= 2 && kk <= now; kk++)
          dp[i + 1][k][kk] =
              max(dp[i + 1][k][kk], dp[i][j][k] + kk + (now - kk) / 3);
      }
    }
  }
  cout << dp[m + 1][0][0] << endl;
  return 0;
}
