#include <bits/stdc++.h>
using namespace std;
int f[1000005];
int n, m, dp[1000005][5][5];
int solve(int pos, int prev1, int prev2) {
  if (pos > m) {
    return 0;
  }
  if (dp[pos][prev1][prev2] != -1) return dp[pos][prev1][prev2];
  int minx = min(prev1, prev2);
  minx = min(minx, f[pos]);
  int ans = 0;
  for (int i = 0; i <= minx; i++) {
    int rem1 = prev2 - i;
    int rem2 = f[pos] - i;
    for (int j = 0; j <= 4; j++) {
      if (rem2 < j) continue;
      int lol = (rem2 - j) / 3;
      ans = max(ans, solve(pos + 1, rem1, j) + i + lol);
    }
  }
  return dp[pos][prev1][prev2] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    f[x]++;
  }
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  ans = max(ans, solve(3, f[1] % 3, f[2] % 3) + f[1] / 3 + f[2] / 3);
  for (int i = 0; i <= 4; i++) {
    for (int j = 0; j <= 4; j++) {
      if (f[1] < i || f[2] < j) continue;
      int rem1 = f[1] - i;
      int rem2 = f[2] - j;
      ans = max(ans, solve(3, i, j) + (f[1] - i) / 3 + (f[2] - j) / 3);
    }
  }
  cout << ans;
}
