#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n, k, m;
int gen[100005];
int kind[100005], appear[100005];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> gen[i];
  for (int i = 0; i < n; ++i) {
    int j = i;
    while (j < n && gen[j] == gen[i]) ++j;
    kind[m++] = gen[i];
    i = j - 1;
  }
  for (int i = 0; i < m; ++i) {
    ++appear[kind[i]];
    if (i > 0 && i < m - 1 && kind[i - 1] == kind[i + 1]) ++appear[kind[i]];
  }
  int res = -1;
  for (int i = 0; i < k + 1; ++i)
    if (res == -1 || appear[i] > appear[res]) res = i;
  printf("%d\n", res);
  return 0;
}
