#include <bits/stdc++.h>
using namespace std;
int ans[100000];
int n, k, x;
int main() {
  cin >> n >> k >> x;
  ans[0] = -1;
  ans[n + 1] = -1;
  for (int i = 1; i <= n; ++i) cin >> ans[i];
  int max_ = 0;
  for (int i = 1; i <= n; ++i)
    if (ans[i] == x) {
      int l = i;
      int r = i;
      int l2 = l, r2 = r;
      bool f = 1;
      int add = 1;
      int tmp = -1;
      while (f) {
        while (ans[r + 1] == ans[r2]) ++r;
        while (l >= 0 && ans[l] == ans[r2]) --l;
        if (r - l - tmp < 3)
          f = 0;
        else
          tmp = r - l;
        ++r;
        l2 = l;
        r2 = r;
        add = 0;
      }
      max_ = max(max_, tmp);
    }
  cout << max(0, max_);
  return 0;
}
