#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, M = 0;
  scanf("%d%d", &N, &K);
  static int A[100000];
  for (int i = 0; i < N; i++) {
    int X;
    scanf("%d", &X);
    X--;
    if (!M || X != A[M - 1]) A[M++] = X;
  }
  static int Count[100000];
  for (int i = 0; i < M; i++) Count[A[i]]++;
  for (int i = 1; i + 1 < M; i++)
    if (A[i - 1] == A[i + 1]) Count[A[i]]++;
  int Ans = 0;
  for (int i = 1; i < K; i++)
    if (Count[i] > Count[Ans]) Ans = i;
  printf("%d\n", Ans + 1);
  return 0;
}
