#include <bits/stdc++.h>
using namespace std;
int n;
int i, j, k;
int a[111111];
int s[111111];
int l;
int r;
int main() {
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  a[n + 1] = a[0] = -1;
  int pre = 0, sum = 0;
  for (i = 1; i < n; i++) sum += (a[i] != a[i + 1]);
  for (i = 1; i <= k; i++) s[i] = sum;
  for (i = 1; i <= n;) {
    r = i;
    while (a[r] == a[i]) {
      r++;
    }
    if (a[r] == a[pre])
      s[a[i]] -= 2;
    else
      s[a[i]]--;
    pre = r - 1;
    i = pre + 1;
  }
  int ans, minv = 10000000;
  for (i = 1; i <= k; i++) {
    if (minv > s[i]) {
      minv = s[i];
      ans = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
