#include <bits/stdc++.h>
using namespace std;
int n, k, a[100010], b[100010], c[100010];
void nhap() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  int dem = 1;
  a[1] = c[1];
  for (int i = 2; i <= n; i++)
    if (c[i] != a[dem]) {
      dem++;
      a[dem] = c[i];
    }
  n = dem;
}
void xuli() {
  a[0] = 0;
  a[n + 1] = 0;
  memset(b, 0, sizeof b);
  for (int i = 1; i <= n; i++)
    if (a[i - 1] == a[i + 1])
      b[a[i]] += 2;
    else
      b[a[i]]++;
  int dem = 0, kq;
  for (int i = 1; i <= k; i++)
    if (dem < b[i]) dem = b[i], kq = i;
  cout << kq;
}
int main() {
  if (0) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  };
  nhap();
  xuli();
  return 0;
}
