#include <bits/stdc++.h>   using namespace std;   int destroy(list<int> row) {     int totalDestroyed = 0, lastDestroyed = -1;     int combo = 1;     while (lastDestroyed != 0) {       lastDestroyed = 0;       combo = 1;       list<int>::iterator it = row.begin();       list<int>::iterator prev = it++;       for (; it != row.end(); ++it) {         if (*prev == *it) {           combo++;         } else {           if (combo >= 3) {             it = row.erase(prev, it);             lastDestroyed += combo;           }           prev = it;           combo = 1;         }       }       totalDestroyed += lastDestroyed;     }     totalDestroyed += (combo >= 3 ? combo : 0);     return totalDestroyed > 0 ? totalDestroyed - 1 : 0;   }   int main() {     int N, K, X;     cin >> N >> K >> X;     list<int> row;     int ball;     for (int i = 0; i < N; ++i) {       cin >> ball;       row.push_back(ball);     }     int maxDestroyed = 0;     for (list<int>::iterator it = row.begin(); it != row.end(); ++it) {       it = row.insert(it, X);       int destroyed = destroy(row);       maxDestroyed = max(maxDestroyed, destroyed);       it = row.erase(it);     }     cout << maxDestroyed;   }   