#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int maxn = 10000;
bool is_prime(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return 0;
  }
  if (x < 2) return 0;
  return 1;
}
int main() {
  int cc, n;
  cin >> cc >> n;
  vector<int> a(n);
  for (int i = 0; i < cc; i++) {
    int x;
    cin >> x;
    x--;
    a[x]++;
  }
  vector<std::vector<int> > dp(3, std::vector<int>(3, 0));
  for (int i = 0; i < n; i++) {
    int c = a[i];
    vector<std::vector<int> > new_dp(3, std::vector<int>(3, 0));
    for (int x = 0; x < 3; x++) {
      for (int y = 0; y < 3; y++) {
        for (int z = 0; z < 3; z++) {
          if (x + y + z <= c) {
            new_dp[y][z] =
                max(new_dp[y][z], dp[x][y] + z + (c - x - y - z) / 3);
          }
        }
      }
    }
    swap(dp, new_dp);
  }
  cout << dp[0][0];
  return 0;
}
