#include <bits/stdc++.h>
using namespace std;
namespace io {
inline void readl(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline void read(int &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
}  // namespace io
using namespace io;
int n, m;
int cnt[1000005], f[1000005][3][3];
int main() {
  int x, ans = 0;
  read(n), read(m);
  for (int i = 1; i <= n; i++) {
    read(x);
    cnt[x]++;
  }
  memset(f, -1, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int a = 0; a < 3; a++) {
      for (int b = 0; b < 3; b++) {
        for (int c = 0; c < 3; c++) {
          int tmp = cnt[i] - a - b - c;
          if (tmp >= 0 && f[i - 1][b][c] >= 0) {
            f[i][a][b] = max(f[i][a][b], f[i - 1][b][c] + c + tmp / 3);
          }
        }
      }
    }
  }
  for (int a = 0; a < 3; a++) {
    for (int b = 0; b < 3; b++) {
      ans = max(ans, f[m][a][b]);
    }
  }
  printf("%d", ans);
  return 0;
}
