#include <bits/stdc++.h>
using namespace std;
template <class T>
T f_min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T f_max(T x, T y) {
  return x > y ? x : y;
}
template <class T>
T f_abs(T x) {
  return x < 0 ? -x : x;
}
template <class T>
T gcd(T x, T y) {
  while (T t = x % y) x = y, y = t;
  return y;
}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;
bool isdig(char x) { return x >= '0' && x <= '9'; }
bool isup(char x) { return x >= 'A' && x <= 'Z'; }
bool isdown(char x) { return x >= 'a' && x <= 'z'; }
bool islet(char x) { return isup(x) || isdown(x); }
int N, K, num[100005];
void get_data() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> num[i];
}
int red[100005];
void run() {
  int tot = 0;
  for (int i = 1; i <= N - 1; i++) {
    if (num[i] != num[i - 1]) tot++;
  }
  memset(red, 0, sizeof(red));
  ;
  int s, e;
  for (s = 0; s < N; s = e) {
    for (e = s; e < N && num[e] == num[s]; e++)
      ;
    int bf, af, org = 0, now = 0;
    if (s)
      bf = num[s - 1], org++;
    else
      bf = -1;
    if (e < N)
      af = num[e], org++;
    else
      af = -2;
    if (af >= 0 && bf >= 0 && af != bf)
      now = 1;
    else
      now = 0;
    red[num[s]] += now - org;
  }
  int res = 1;
  for (int i = 1; i <= K; i++) {
    if (red[i] < red[res]) res = i;
  }
  cout << res << endl;
}
int main() {
  get_data();
  run();
  return 0;
}
