#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
int N, K, M;
int arr[100011], cnt[100011];
int main() {
  if (fopen("data.in", "r")) freopen("data.in", "r", stdin);
  scanf("%d", &N);
  scanf("%d", &K);
  for (int i = 0; i < N; i++) {
    int input = 0;
    scanf("%d", &input);
    if (input != arr[M]) arr[++M] = input;
  }
  for (int i = 1; i <= M; i++) cnt[arr[i]] += 1 + (arr[i - 1] == arr[i + 1]);
  int ans = 1;
  for (int i = 1; i <= K; i++)
    if (cnt[i] > cnt[ans]) ans = i;
  printf("%d\n", ans);
  return 0;
}
