#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int mod = 1e9 + 7;
int t[N], dp[2][3][3];
int main() {
  int n, K;
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    t[x]++;
  }
  int cur = 1, pre = 0;
  for (int i = 1; i <= K; i++) {
    memset(dp[cur], 0, sizeof(dp[cur]));
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        for (int l = 0; l < 3; l++)
          if (j + k + l <= t[i])
            dp[cur][k][l] =
                max(dp[cur][k][l], dp[pre][j][k] + l + (t[i] - j - k - l) / 3);
    swap(cur, pre);
  }
  printf("%d\n", dp[pre][0][0]);
  return 0;
}
