#include <bits/stdc++.h>
using namespace std;
int dp[1234657][3][3];
int s[1234657], n, m, x;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    s[x]++;
  }
  for (int i = 1; i <= m; i++)
    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 > s[i]) continue;
          dp[i][y][z] =
              max(dp[i][y][z], dp[i - 1][x][y] + z + (s[i] - x - y - z) / 3);
        }
  printf("%d\n", dp[m][0][0]);
  return 0;
}
