#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const long long INFLL = 0x3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, m, a[maxn], dp[maxn][3][3];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0, x; i < n; i++) {
    scanf("%d", &x);
    a[x]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int q = 0; q < 3; q++) {
          if (j + k + q > a[i]) continue;
          dp[i][k][q] =
              max(dp[i][k][q], dp[i - 1][j][k] + q + (a[i] - j - k - q) / 3);
        }
      }
    }
  }
  printf("%d\n", dp[m][0][0]);
  return 0;
}
