#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c;
  cin >> n >> k >> c;
  vector<int> vi;
  int temp;
  for (int x = 0; x < n; x++) {
    cin >> temp;
    vi.push_back(temp);
  }
  int max = 0;
  int cur = 0;
  int p1, p2;
  for (int x = 1; x < n; x++) {
    vector<int> vi1 = vi;
    p1 = x - 1;
    p2 = x;
    int n1 = n;
    int c1 = c;
    int c2 = c;
    int trig = 0;
    while (1) {
      if (p1 < 0 || p2 > n - 1) {
        break;
      }
      if (vi1[p1] == c1 && vi1[p2] == c2) {
        if (cur == 0) {
          if (p1 != 0) {
            if (vi1[p1 - 1] == c1) {
              cur++;
              p1 -= 1;
            }
          }
          if (p2 != n - 1) {
            if (vi1[p2 + 1] == c2) {
              cur++;
              p2++;
            }
          }
        } else if (cur > 0) {
          if (p1 != 0) {
            if (vi1[p1 - 1] == vi1[p2]) {
              trig = 1;
              cur++;
              p1 -= 1;
            }
          }
          if (p2 != n - 1) {
            if (vi1[p2 + 1] == vi1[p2]) {
              trig = 1;
              cur++;
              p2++;
            }
          }
          if (trig != 1) {
            break;
          } else {
            trig = 0;
          }
        }
        cur += 2;
        p1--;
        p2++;
        if (p1 < 0 || p2 >= n) {
          break;
        }
        c1 = vi1[p2];
        c2 = vi1[p1];
      } else {
        break;
      }
    }
    if (cur > max) {
      max = cur;
    }
    cur = 0;
  }
  cout << max << endl;
}
