#include <bits/stdc++.h>
using namespace std;
int n, k, t, a[100 + 2], ans;
int cal(int x) {
  int cnt = 0;
  for (register int i = x; a[i] == a[x]; i--) cnt++;
  for (register int i = x; a[i] == a[x]; i++) cnt++;
  return cnt - 1;
}
int main() {
  cin >> n >> k >> t;
  for (register int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    if (cal(i) == 2 && a[i] == t) {
      int j, k;
      for (j = i; a[i] == a[j]; j--)
        ;
      for (k = i; a[i] == a[k]; k++)
        ;
      while (1) {
        if (a[j] != a[k] || !j || k == n + 1) break;
        int x = j, y = k;
        while (a[j] == a[x]) j--;
        while (a[k] == a[x]) k++;
        if (x - j + k - y >= 3)
          continue;
        else {
          j = x, k = y;
          break;
        }
      }
      j++, k--;
      ans = max(ans, k - j + 1);
    }
  cout << ans << endl;
  return 0;
}
