Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? 

There are *n* balls put in a row. Each ball is colored in one of *k* colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color *x*. He can insert his ball at any position in the row (probably, between two other balls). If at any moment there are three or more contiguous balls of the same color in the row, they are destroyed immediately. This rule is applied multiple times, until there are no more sets of 3 or more contiguous balls of the same color. 

For example, if Iahub has the row of balls [black, black, white, white, black, black] and a white ball, he can insert the ball between two white balls. Thus three white balls are destroyed, and then four black balls become contiguous, so all four balls are destroyed. The row will not contain any ball in the end, so Iahub can destroy all 6 balls.

Iahub wants to destroy as many balls as possible. You are given the description of the row of balls, and the color of Iahub's ball. Help Iahub train for the IOI by telling him the maximum number of balls from the row he can destroy.
The first line of input contains three integers: *n* (1 ≤ *n* ≤ 100), *k* (1 ≤ *k* ≤ 100) and *x* (1 ≤ *x* ≤ *k*). The next line contains *n* space-separated integers *c*<sub class="lower-index">1</sub>, *c*<sub class="lower-index">2</sub>, ..., *c*<sub class="lower-index">*n*</sub> (1 ≤ *c*<sub class="lower-index">*i*</sub> ≤ *k*). Number *c*<sub class="lower-index">*i*</sub> means that the *i*-th ball in the row has color *c*<sub class="lower-index">*i*</sub>.

It is guaranteed that the initial row of balls will never contain three or more contiguous balls of the same color.
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')





def solve():
    
    
    
    n,k,x=mi()
    
    a=li()
    x1=[]
    c=1
    for i in range(1,n):
        if a[i]!=a[i-1]:
            x1.append([c,a[i-1]])
            c=1
        else:
            c+=1
    x1.append([c,a[n-1]])
    ans=0
    st=[]
    i=0
    while(i<len(x1)):
        if len(st)==0:
            if x1[i][0]>2:
                ans+=x1[i][0]
                i+=1
            elif(x1[i][0]>1 and x1[i][1]==x):
                ans+=x1[i][0]
                i+=1
            else:
                st.append(x1[i])
                i+=1
        else:
            x2=st[len(st)-1]
            if x2[1]==x1[i][1]:
                if x2[0]+x1[i][0]>2:
                    ans+=(x2[0]+x1[i][0])
                    st.pop()
                    i+=1
                else:
                    st[len(st)-1][0]+=x1[i][0]
                    i+=1
            else:
                if x1[i][0]>2:
                    ans+=x1[i][0]
                    i+=1
                elif(x1[i][0]>1 and x1[i][1]==x):
                    ans+=x1[i][0]
                    i+=1
                else:
                    st.append(x1[i])
                    i+=1
    print(ans)
            
            
        
    
    
    
    
    
    
    
    
    
        
        
        
        
if __name__ =="__main__":
    solve()
