#include <bits/stdc++.h>
using namespace std;
int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};
struct i {
  int color, cnt;
};
int main() {
  int n, k, x;
  scanf("%d%d%d", &n, &k, &x);
  int arr[n];
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  vector<i> info;
  int color = arr[0], cnt = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == color)
      cnt++;
    else {
      info.push_back({color, cnt});
      color = arr[i], cnt = 1;
    }
  }
  info.push_back({color, cnt});
  int mx = 0;
  for (int i = 0; i < info.size(); i++) {
    if (info[i].color == x && info[i].cnt + 1 >= 3) {
      int c = info[i].cnt, l = i - 1, r = i + 1;
      while (l >= 0 && r < info.size() && info[l].color == info[r].color) {
        if (info[l].cnt + info[r].cnt >= 3)
          c += info[l].cnt + info[r].cnt, l--, r++;
        else
          break;
      }
      mx = max(mx, c);
    }
  }
  printf("%d", mx);
}
