#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, c, tmp;
  cin >> n >> c;
  long long ar[n];
  long long dp[500005] = {0};
  for (long long int i = 0; i < n; i++) cin >> ar[i];
  long long ans = 0, cnt = 0;
  for (long long int i = 0; i < n; i++) {
    if (ar[i] == c)
      cnt++;
    else {
      dp[ar[i]] = max(dp[ar[i]], cnt) + 1;
    }
    ans = max(ans, dp[ar[i]] - cnt);
  }
  cout << ans + cnt << '\n';
  return 0;
}
