#include <bits/stdc++.h>
int b[100005], a[100005], n, x, A, k;
int main() {
  while (~scanf("%d %d", &n, &k)) {
    memset(b, 0, sizeof(b));
    scanf("%d", &a[1]);
    x = 2;
    for (int i = 2; i <= n; i++) {
      scanf("%d", &A);
      if (A != a[x - 1]) a[x++] = A;
    }
    for (int i = 1; i < x; i++) {
      b[a[i]]++;
      if (i < x - 1 && i > 0) {
        if (a[i - 1] == a[i + 1]) b[a[i]]++;
      }
    }
    int y = 1;
    if (x == k + 1)
      printf("1\n");
    else {
      for (int i = 2; i <= k; i++) {
        if (b[i] > b[y]) y = i;
      }
      printf("%d\n", y);
    }
  }
  return 0;
}
