#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
const int MAXN = 1e3 + 10;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
int n, m;
int base[1000010];
int mp[1000010];
int dp[1000010][3][3];
int main() {
  scanf("%d%d", &n, &m);
  memset(mp, 0, sizeof(mp));
  int minx = INF;
  int maxx = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &base[i]);
    mp[base[i]]++;
    if (base[i] < minx) minx = base[i];
    if (base[i] > maxx) maxx = base[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (dp[i - 1][j][k] < 0) continue;
        for (int l = 0; l < 3; l++) {
          if (mp[i] - j - k - l < 0) continue;
          dp[i][k][l] =
              max(dp[i][k][l], dp[i - 1][j][k] + (mp[i] - j - k - l) / 3 + j);
          ans = max(ans, dp[i][k][l]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
