#include <bits/stdc++.h>
int a[100100];
int n, k, nr;
int g[100100];
int main() {
  scanf("%d %d", &n, &k);
  nr = 0;
  for (int i = 0; i < n; ++i) {
    int v;
    scanf("%d", &v);
    if (nr > 0 && a[nr - 1] == v) continue;
    a[nr++] = v;
  }
  memset(g, 0, sizeof(g));
  for (int i = 0; i < nr; ++i) {
    int v = a[i];
    if (i == 0 || i == nr - 1)
      ++g[v];
    else {
      g[v] += 2;
      if (a[i - 1] != a[i + 1]) --g[v];
    }
  }
  int best = 1;
  for (int i = 1; i <= k; ++i) {
    if (g[i] > g[best]) best = i;
  }
  printf("%d\n", best);
  return 0;
}
