#include <bits/stdc++.h>
using namespace std;
template <class T>
void rd(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}
const int N = 1e6;
int a[N + 5];
long long f[2][6][6];
int n, m;
long long cmax(long long &a, long long b) { a = max(a, b); }
int main() {
  rd(n), rd(m);
  for (register int i = (1); i <= (n); ++i) {
    int x;
    rd(x);
    a[x]++;
  }
  memset(f, -0x3f, sizeof(f));
  f[0][0][0] = 0;
  int u = 0, v = 1;
  for (register int i = (1); i <= (N); ++i) {
    swap(u, v);
    memset(f[u], -0x3f, sizeof(f[u]));
    for (register int j = (0); j <= (2); ++j)
      for (register int k = (0); k <= (2); ++k)
        for (register int h = (0); h <= (2); ++h)
          if (j + k + h <= a[i])
            cmax(f[u][k][h], f[v][j][k] + h + (a[i] - j - k - h) / 3);
  }
  printf("%lld\n", f[u][0][0]);
  return 0;
}
