#include <bits/stdc++.h>
using namespace std;
int n, c, arr[500005] = {0}, con = 0, num, add = 0;
int main() {
  int n, c;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num == c)
      con++;
    else {
      if (arr[num] - con < 0) arr[num] = con;
      arr[num]++;
      add = max(add, arr[num] - con);
    }
  }
  cout << add + con;
}
