#include <bits/stdc++.h>
using namespace std;
const int nn = 5e5 + 5;
int arr[nn], frek[nn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, c, cnt = 0, cnt2 = 0;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == c) cnt++;
  }
  int ans = cnt;
  for (int i = 0; i < n; i++) {
    if (arr[i] == c)
      cnt2++;
    else if (frek[arr[i]] < cnt2)
      frek[arr[i]] = cnt2;
    frek[arr[i]]++;
    ans = max(ans, frek[arr[i]] + cnt - cnt2);
  }
  cout << ans << "\n";
}
