#include <bits/stdc++.h>
void fo() { fflush(stdout); }
using namespace std;
int n, k, id;
int a[100000];
int change[100001];
int main() {
  scanf("%d%d", &n, &k);
  scanf("%d", a);
  for (int i = 1; i < n; i++) {
    int t;
    scanf("%d", &t);
    if (a[id] == t)
      continue;
    else
      a[++id] = t;
  }
  n = id + 1;
  for (int i = 0; i < n; i++) {
    if (i == 0 || i + 1 == n) {
      change[a[i]]++;
      continue;
    }
    if (a[i - 1] == a[i + 1])
      change[a[i]] += 2;
    else
      change[a[i]]++;
  }
  int ans = 1;
  for (int i = 1; i <= k; i++) {
    if (change[i] > change[ans]) ans = i;
  }
  printf("%d\n", ans);
  return 0;
}
