#include <bits/stdc++.h>
using namespace std;
int n, k, x, ans, t[105];
int main() {
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 0; i <= n; i++) {
    int L = i, R = i + 1, cnt = 1, cur = x, preL, preR;
    while (1) {
      preL = L, preR = R;
      while (L && t[L] == cur) {
        L--;
        cnt++;
      }
      while (R <= n && t[R] == cur) {
        R++;
        cnt++;
      }
      if (cnt <= 2) {
        L = preL;
        R = preR;
        break;
      } else
        cur = t[L], cnt = 0;
    }
    ans = max(ans, R - L - 1);
  }
  printf("%d", ans);
  return 0;
}
