#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, m, c, ans;
int a[maxn];
vector<int> st;
int main() {
  scanf("%d%d%d", &n, &m, &c);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i + 1] && a[i] == c) {
      st.push_back(i);
    }
  }
  for (int i = 0, l, r, tot; i < st.size(); ++i) {
    l = st[i] - 1, r = st[i] + 2;
    tot = 2;
    for (int flag; l > 0 && r <= n;) {
      flag = 0;
      if (a[l] == a[r]) {
        if (r + 1 <= n && a[r] == a[r + 1]) {
          flag = 1;
          while (r + 1 <= n && a[r] == a[r + 1]) {
            ++r;
            ++tot;
          }
        }
        if (l - 1 > 0 && a[l] == a[l - 1]) {
          flag = 1;
          while (l - 1 > 0 && a[l] == a[l - 1]) {
            --l;
            ++tot;
          }
        }
        if (flag) {
          --l;
          ++r;
          ++ ++tot;
        } else {
          break;
        }
      } else {
        break;
      }
    }
    ans = max(ans, tot);
  }
  printf("%d", ans);
  return 0;
}
