#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int ans;
} s2[105];
int s1[105];
int main() {
  int k = 1, k1, n, x, y;
  scanf("%d%d%d", &n, &k1, &x);
  scanf("%d", &s1[1]);
  s2[k].x = s1[1];
  s2[k].ans++;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &s1[i]);
    if (s1[i] == s2[k].x)
      s2[k].ans++;
    else {
      k++;
      s2[k].x = s1[i];
      s2[k].ans++;
    }
  }
  int max2 = -1;
  for (int j = 1; j <= k; j++) {
    int sum = 0;
    if (s2[j].x == x && s2[j].ans == 2) {
      sum += s2[j].ans;
      int l = j, r = j;
      while (1) {
        l--;
        r++;
        if (s2[l].x == s2[r].x && (s2[l].ans + s2[r].ans >= 3) && l >= 1 &&
            r <= k)
          sum += s2[l].ans + s2[r].ans;
        else
          break;
      }
    }
    max2 = max(max2, sum);
  }
  printf("%d\n", max2);
  return 0;
}
