#include <bits/stdc++.h>
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
int dp[1000005][3][3];
int n, m;
int s[1000005];
int main() {
  n = rd(), m = rd();
  for (int i = 1; i <= n; i++) {
    int x = rd();
    s[x]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= 2; j++) {
      for (int k = 0; k <= 2; k++) {
        dp[i][j][k] = -1e9;
        for (int t = 0; t <= 2; t++)
          if (j + k + t <= s[i] && k + t <= s[i]) {
            dp[i][j][k] = std::max(
                dp[i][j][k], dp[i - 1][k][t] + (s[i] - j - k - t) / 3 + j);
          }
      }
    }
  }
  wrt(dp[m][0][0], '\n');
}
