#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main(int argc, char const *argv[]) {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  srand(time(NULL));
  int cc, n;
  cin >> cc >> n;
  vector<int> a(n, 0);
  for (long long i = 0; i <= cc - 1; ++i) {
    int x;
    cin >> x;
    x--;
    a[x]++;
  }
  vector<vector<int>> dp(3, vector<int>(3, 0));
  for (int c : a) {
    vector<vector<int>> new_dp(3, 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] << endl;
  return 0;
}
