#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int dp[N], cnt[N], a[N];
unordered_map<int, int> mp;
int main() {
  int n, c, ans = -1;
  cin >> n >> c;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    cnt[i] = cnt[i - 1] + (a[i] == c);
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = max(cnt[i - 1] + 1, dp[mp[a[i]]] + 1);
    ans = max(ans, dp[i] + cnt[n] - cnt[i]);
    mp[a[i]] = i;
  }
  cout << ans << endl;
}
