#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
inline T gethash(T h[], T power[], int l, int r) {
  if (r < l) return (T)0;
  return h[l] - h[r + 1] * power[r - l + 1];
}
struct data {
  data() {}
  bool friend operator<(data a, data b) { return 0; }
};
int n, m, k;
long long N, M, K;
vector<int> ve;
vector<int> ashol;
int vis[104];
int main() {
  int t, tc = 1;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    ve.push_back(p);
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    memset(vis, 0, sizeof vis);
    vector<int> temp;
    for (int j = 0; j <= i; j++) {
      temp.push_back(ve[j]);
    }
    temp.push_back(k);
    for (int j = i + 1; j < n; j++) {
      temp.push_back(ve[j]);
    }
    int tot = 0;
    while (1) {
      int ct = 1;
      int ck = 0;
      int pre;
      int st = 0;
      for (int j = 0; j < temp.size(); j++) {
        if (vis[j] == 0) {
          pre = temp[j];
          st = j + 1;
          break;
        }
      }
      for (int j = st; j < temp.size(); j++) {
        if (vis[j]) continue;
        if (temp[j] == pre) {
          ct++;
        } else {
          if (ct >= 3) {
            tot += ct;
            ck = 1;
            int tp = ct;
            for (int k = j - 1; k >= 0; k--) {
              if (vis[k] == 0) {
                vis[k] = 1;
                tp--;
                if (tp == 0) break;
              }
            }
          }
          ct = 1;
        }
        pre = temp[j];
      }
      if (ct >= 3) {
        tot += ct;
        ck = 1;
        int tp = ct;
        for (int k = temp.size() - 1; k >= 0; k--) {
          if (vis[k] == 0) {
            vis[k] = 1;
            tp--;
            if (tp == 0) break;
          }
        }
      }
      if (ck == 0) break;
    }
    mx = max(tot, mx);
  }
  if (mx > 0) mx--;
  printf("%d", mx);
  return 0;
}
