#include <bits/stdc++.h>
using namespace std;
int n, m, X;
bool ok[110];
int a[110], b[110];
int get(int pos) {
  int nn = n + 1;
  memset(b, 0, sizeof(b));
  int res = 0;
  for (int i = 1; i <= pos - 1; i++) b[i] = a[i];
  b[pos] = X;
  for (int i = pos; i <= n; i++) b[i + 1] = a[i];
  while (nn >= 2) {
    bool found = 0;
    memset(ok, 1, sizeof(ok));
    int last = 1;
    for (int i = 2; i <= nn; i++)
      if (b[i] != b[last]) {
        if (i - last > 2) {
          for (int j = last; j <= i - 1; j++) ok[j] = 0;
          found = 1;
        }
        last = i;
      }
    int cnt = 0;
    if (nn - last > 1)
      for (int j = last; j <= nn; j++) ok[j] = 0;
    for (int i = 1; i <= nn; i++)
      if (ok[i])
        cnt++, b[cnt] = b[i];
      else
        res++;
    nn = cnt;
    if (!found) break;
  }
  return res - 1;
}
int main() {
  cin >> n >> m >> X;
  int sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int res = 0;
  for (int i = 2; i <= n; i++)
    if (a[i] == a[i - 1]) {
      res = max(res, get(i));
      res = max(res, get(i - 1));
    }
  cout << res;
}
