#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
template <typename X>
inline bool minimize(X& p, X q) {
  if (p <= q) return 0;
  p = q;
  return 1;
}
template <typename X>
inline bool maximize(X& p, X q) {
  if (p >= q) return 0;
  p = q;
  return 1;
}
const int MAXN = 100005;
int A[MAXN], cnt[MAXN];
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%d", A + i);
  A[0] = A[N + 1] = -1;
  for (int i = 1, j = 2; i <= N; i = j++) {
    while (A[j] == A[i]) ++j;
    ++cnt[A[i]];
    if (A[i - 1] == A[j]) ++cnt[A[i]];
  }
  int ans = 1;
  for (int i = 2; i <= K; ++i)
    if (cnt[i] > cnt[ans]) ans = i;
  printf("%d\n", ans);
  return 0;
}
