#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
const int N = 1e6 + 10;
long long f[N][3][3], a[N];
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++i) a[read()]++;
  memset(f, -0x3f, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 1; i <= m; ++i) {
    for (int x = 0; x < 3; ++x)
      for (int y = 0; y < 3; ++y)
        for (int z = 0; z < 3; ++z) {
          if (a[i] < x + y + z) continue;
          f[i][x][y] =
              max(f[i][x][y], f[i - 1][z][x] + (a[i] - x - y - z) / 3 + z);
        }
  }
  cout << f[m][0][0];
  return 0;
}
