#include <bits/stdc++.h>
using namespace std;
int N, K, A[100005], R[100005], X, i;
int main() {
  cin >> N >> K;
  for (i = 1; i <= N; i++) cin >> A[i], K = 1;
  for (i = 2; i <= N; i++)
    if (A[i] != A[i - 1]) A[++K] = A[i];
  N = K, R[A[1]]++, R[A[N]]++, K = 0;
  for (i = 2; i <= N - 1; i++) R[A[i]] += A[i + 1] != A[i - 1] ? 1 : 2;
  for (i = 1; i <= 100000; i++)
    if (R[i] > K) K = R[i], X = i;
  cout << X;
}
