A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.

On the i-th day the festival will show a movie of genre a_{i}. We know that a movie of each of k genres occurs in the festival programme at least once. In other words, each integer from 1 to k occurs in the sequence a_1, a_2, ..., a_{n} at least once.

Valentine is a movie critic. He wants to watch some movies of the festival and then describe his impressions on his site.

As any creative person, Valentine is very susceptive. After he watched the movie of a certain genre, Valentine forms the mood he preserves until he watches the next movie. If the genre of the next movie is the same, it does not change Valentine's mood. If the genres are different, Valentine's mood changes according to the new genre and Valentine has a stress.

Valentine can't watch all n movies, so he decided to exclude from his to-watch list movies of one of the genres. In other words, Valentine is going to choose exactly one of the k genres and will skip all the movies of this genre. He is sure to visit other movies.

Valentine wants to choose such genre x (1 ≤ x ≤ k), that the total number of after-movie stresses (after all movies of genre x are excluded) were minimum.


-----Input-----

The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), where n is the number of movies and k is the number of genres.

The second line of the input contains a sequence of n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k), where a_{i} is the genre of the i-th movie. It is guaranteed that each number from 1 to k occurs at least once in this sequence.


-----Output-----

Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.


-----Examples-----
Input
10 3
1 1 2 3 2 3 3 1 1 3

Output
3
Input
7 3
3 1 3 2 3 1 2

Output
1


-----Note-----

In the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stresses.

In the second sample whatever genre Valentine excludes, he will have exactly 3 stresses.

Difficulty: interview

Starter code:

Solutions:
n, k = map(int, input().split())
t = list(map(int, input().split()))
t = [t[0]] + [t[i] for i in range(1, len(t)) if t[i] != t[i - 1]]
p = [0] * (k + 1)
for i in range(1, len(t) - 1):
    if t[i - 1] == t[i + 1]: p[t[i]] += 2
    else: p[t[i]] += 1
p[t[0]] += 1
p[t[-1]] += 1
print(p.index(max(p)))

import sys

def solve():
    n, k = map(int, input().split())
    bada = list(map(int, input().split()))
    a = list()
    for i in range(len(bada)):
        if len(a) > 0 and bada[i] == a[-1]: continue
        a.append(bada[i])
    bad = [0] * (k + 1)
    for i, val in enumerate(a):
        if i + 1 >= len(a) and i == 0: continue
        if i + 1 >= len(a):
            bad[val] += 1
        elif i == 0:
            bad[val] += 1
        else:
            before = a[i-1]
            after = a[i+1]
            bad[val] += 2 if before == after else 1
    which = -1
    howmany = -1
    for i in range(len(bad)):
        if bad[i] > howmany:
            which = i
            howmany = bad[i]
    print(which)


if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

__author__ = 'Michael Ilyin'


def prepare(a):
    na = []
    last = 0
    for i in range(0, len(a)):
        if last != a[i]:
            na.append(a[i])
            last = a[i]
    return na


header = input()
films = int(header[:header.find(' ')])
genres = int(header[header.find(' '):])
numbers = [int(x) for x in input().split()]
res = [[genre, 0] for genre in range(1, genres + 1)]
numbers = prepare(numbers)
films = len(numbers)

for i, obj in enumerate(numbers):
    if i == 0:
        res[obj - 1][1] += 1
        continue
    if i == films - 1:
        res[obj - 1][1] += 1
        continue
    if numbers[i - 1] == numbers[i + 1]:
        res[obj - 1][1] += 2
    else:
        res[obj - 1][1] += 1
res = sorted(res, key=lambda x: x[0], reverse=False)
res = sorted(res, key=lambda x: x[1], reverse=True)
print(str(res[0][0]))

# 1  2  3  2  3  1  3
#  12 23 32 23 31 13
# 1 1 2 3 2 3 3 1 1 3
#      112 123 232 323 233 331 311 113
# 12/21  1   0   0   0   0   1   0   0
# 23/32  0   1   1   1   0   0   0   0
# 13/31  0   1   0   0   0   1   0   0


# 1 2 3 1 2 3 1 2 3| 1
# 	    123 231 312 123 231 312 123 231
# 12/21  1   1   1   0   1   1   0   1    
# 23/32  1   1   0   1   0   1   1   0
# 13/31  1   1   0   1   1   0   1   1

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
	# (n,k) = [int(x) for x in inputFile.readline().strip().split(' ')]
	# dataF = inputFile.readline().strip().split(' ');
(n,k) = [int(x) for x in input().strip().split(' ')]
dataF = input().strip().split(' ');
dataF = [int(x) for x in dataF]
data = [0]
for i in range(len(dataF)):
	if (data[len(data)-1] != dataF[i]):
		data.append(dataF[i])
data = data[1:]
res = {x:0 for x in set(data)}
res[data[0]] += 1
res[data[len(data)-1]] += 1
for i in range(0,len(data)-2,1):
	prev = data[i]
	curr = data[i+1]
	next = data[i+2]
	if (prev == next):
		res[curr] += 2
	if (prev != next):
		res[curr] += 1
print(max(res, key=res.get))

	


num_days, num_genres = list(map(int, input().split()))
schedule = list(map(int, input().split()))

compressed = []
current = schedule[0]
pos = 1
while True:
    compressed.append(current)
    while pos < num_days and schedule[pos] == current:
        pos += 1
    if pos < num_days:
        current = schedule[pos]
    else:
        break

score = (num_genres + 1) * [ 0 ]
score[compressed[0]] += 1
for i in range(2, len(compressed)):
    score[compressed[i - 1]] += 1
    if compressed[i - 2] == compressed[i]:
        score[compressed[i - 1]] += 1
score[compressed[len(compressed) - 1]] += 1

best_score, best_genre = -1, -1
for genre in range(1, num_genres + 1):
    if score[genre] > best_score:
        best_score = score[genre]
        best_genre = genre
print(best_genre)


num_days, num_genres = list(map(int, input().split()))
schedule = list(map(int, input().split()))

compressed = []
current = schedule[0]
pos = 1
while True:
    compressed.append(current)
    while pos < num_days and schedule[pos] == current:
        pos += 1
    if pos < num_days:
        current = schedule[pos]
    else:
        break

score = (num_genres + 1) * [ 0 ]
score[compressed[0]] += 1
for i in range(2, len(compressed)):
    score[compressed[i - 1]] += 1
    if compressed[i - 2] == compressed[i]:
        score[compressed[i - 1]] += 1
score[compressed[len(compressed) - 1]] += 1

best_score, best_genre = -1, -1
for genre in range(1, num_genres + 1):
    if score[genre] > best_score:
        best_score = score[genre]
        best_genre = genre
print(best_genre)




# Made By Mostafa_Khaled


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
a=[0]+a+[0]
i=1 
tot=0 
j=1 
cnt=[0]*(k+1)
while i<=n:
    while j<=n and a[j]==a[i]: j+=1 
    tot+=1 
    if a[i-1]==a[j]:
        cnt[a[i]]+=2 #gain a strain of 2 if we remove a[i]
    else:
        cnt[a[i]]+=1 
    i=j 
tot-=1 
ans=tot
#print(cnt)
for i in range(1,k+1):
    if ans>tot-cnt[i]:
        ans=tot-cnt[i]
        res=i 
print(res)

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

n, k = mints()
a = list(mints())
i = 0
c = [0]*(k+1)
while i < n:
	j = i
	while j < n and a[j] == a[i]:
		j += 1
	if i - 1 >= 0:
		if j < n:
			if a[i-1] != a[j]:
				c[a[i]] += 1
			else:
				c[a[i]] += 2
		else:
			c[a[i]] += 1
	elif j < n:
			c[a[i]] += 1
	i = j
z = 1
for i in range(k+1):
	if c[z] < c[i]:
		z = i
print(z)


n, k = map(int, input().split())
a = [int(i) for i in input().split()]
s = [0 for i in range(k)]
b = [a[0]]
for i in range(1, n):
    if a[i] == b[-1]:
        continue
    else:
        b.append(a[i])
y = len(b)
for i in range(y):
    if i == 0 and b[i] != b[i + 1]:
        s[a[0] - 1] += 1
    elif i == y - 1 and b[i] != b[i - 1]:
        s[b[y - 1] - 1] += 1
    else:
        if b[i - 1] == b[i + 1]:
            s[b[i] - 1] += 2
        else:
                s[b[i] - 1] += 1
x = max(s)
print(s.index(x) + 1)

n, k = list(map(int, input().split()))
t = list(map(int, input().split()))
t = [t[0]] + [t[i] for i in range(1, len(t)) if t[i] != t[i - 1]]
p = [0] * (k + 1)
for i in range(1, len(t) - 1):
    if t[i - 1] == t[i + 1]:
        p[t[i]] += 2
    else:
        p[t[i]] += 1
p[t[0]] += 1
p[t[-1]] += 1
print(p.index(max(p)))


n,k=map(int,input().split())
lst=[*map(int,input().split())]
a,length=[lst[0]],0
for i,x in enumerate(lst[1:]):
    if x!=lst[i]:a.append(x);length+=1
d={i:length for i in range(1,k+1)}
d[a[0]]-=1
for i,x in enumerate(a[1:-1]):
    if a[i]==a[i+2]:d[x]-=2
    else:d[x]-=1
d[a[-1]]-=1
res=min(d.values())
for i,x in enumerate(d):
    if d[x]==res:
        print(x);break

n,k = list(map(int,input().split()))
lis=list(map(int,input().split()))
ans=[]
freq=[0]*(k+1)
for i in range(n-1):
    if lis[i]!=lis[i+1]:
        ans.append(lis[i])
if lis[-1]!=ans[-1]:
    ans.append(lis[-1])
#print(ans,freq)
l=len(ans)
for i in range(1,l-1):
    if ans[i-1]==ans[i+1]:
        freq[ans[i]]+=2
    else:
        freq[ans[i]]+=1
freq[ans[-1]]+=1
freq[ans[0]]+=1        
print(freq.index(max(freq)))            
        




import math
#n,m=map(int,input().split())
from collections import Counter
#for i in range(n):
import math
#for _ in range(int(input())):
#n = int(input())
#for _ in range(int(input())):
#n = int(input())
import bisect
'''for _ in range(int(input())):

    n=int(input())

    n,k=map(int, input().split())

    arr = list(map(int, input().split()))'''
#n, m, k = [int(x) for x in input().split()]
n,m=list(map(int,input().split()))
arr=list(map(int,input().split()))
ls=[0]*(10**5+1)
pre=arr[0]
for i in range(1,n-1):
    if arr[i]!=arr[i+1]:
        ls[arr[i]]+=2 if arr[i+1]==pre else 1
        pre=arr[i]

if arr[0]!=arr[-1]:
    ls[arr[-1]]+=1
    if arr[0]!=arr[1]:
        ls[arr[0]]+=1

var=ls.index(max(ls))
mm=max(ls)
#print(ls[:4])
if m==2:
    if 1 in arr and 2 in arr:
        print(1)
    else:
        print(0)
else:
    for i in range(len(ls)):
        if ls[i] == mm:
            print(i)
            break













n,k=map(int,input().split())
r=list(map(int,input().split()))
dist=[]
ans=[0]*(k+1)#precomp
for i in range(n):
	if i == 0 or r[i] != r[i - 1]:
		dist.append(r[i])
# dist = distinct
for i in range(len(dist)):
	if 0 < i < len(dist) - 1 and dist[i - 1] == dist[i + 1]:
		ans[dist[i]] += 2 # removing dist[i] subtracts 2
	else:
		ans[dist[i]] += 1
u, v = -1, -1
for k in range(1, k + 1):
	if ans[k] > u: u, v = ans[k], k
print (v)