#include <bits/stdc++.h>
using namespace std;
int n, f[1000010][4][4], m;
int a[1000010], b[1000010];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  for (int i = 1; i <= m; i++)
    for (int j = 0; j <= 2; j++)
      for (int k = 0; k <= 2; k++) f[i][j][k] = -0x7fffffff;
  f[1][0][0] = 0;
  for (int i = 2; i <= m + 1; i++)
    for (int j = 0; j <= 2; j++)
      for (int k = 0; k <= 2; k++)
        for (int l = 0; l <= 2; l++) {
          int rem = b[i - 1] - j - k - l;
          if (rem >= 0)
            f[i][j][k] = max(f[i][j][k], f[i - 1][k][l] + l + rem / 3);
        }
  cout << f[m + 1][0][0];
}
