#include <bits/stdc++.h>
using namespace std;
template <class T>
void chkmax(T& x, T y) {
  x = x > y ? x : y;
}
template <class T>
void chkmin(T& x, T y) {
  x = x < y ? x : y;
}
const int N = 1e6 + 5;
int n, m;
int a[N];
int dp[N][3][3];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  memset(dp, ~0x3f, sizeof dp);
  dp[1][0][0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= 2; j++) {
      for (int k = 0; k <= 2; k++) {
        for (int t = 0; t <= 2 && j + k + t <= a[i]; t++) {
          chkmax(dp[i + 1][k][t], dp[i][j][k] + t + (a[i] - j - k - t) / 3);
        }
      }
    }
  }
  printf("%d\n", dp[m + 1][0][0]);
  return 0;
}
