#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
int arr[MAXN];
int pren[MAXN];
int dpl[MAXN];
int dp[MAXN];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = 0;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    dpl[i] = dpl[i - 1];
    if (arr[i] == k) {
      dpl[i]++;
      cnt++;
    } else {
      dp[i] = max(dp[pren[arr[i]]] + 1 - (dpl[i] - dpl[pren[arr[i]]]), 1);
    }
    ans = max(ans, dp[i]);
    pren[arr[i]] = i;
  }
  printf("%d\n", ans + cnt);
  return 0;
}
