#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1e6 + 10, INF = 1e9;
int cnt[N], dp[N][5][5];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= 4; j++)
      for (int k = 0; k <= 4; k++) dp[i][j][k] = -INF;
  dp[0][0][0] = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 0; j <= 4; j++)
      for (int k = 0; k <= 4; k++)
        for (int t = 0; t <= 2; t++)
          if (cnt[i] >= k + t && t + j <= 4)
            dp[i][j][k] = max(dp[i][j][k],
                              t + dp[i - 1][t][t + j] + (cnt[i] - k - t) / 3);
  printf("%d\n", dp[m][0][0]);
  return 0;
}
