#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[100003];
int w[100003];
int main() {
  scanf("%d %d", &n, &k);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x != a[m]) a[++m] = x;
  }
  for (int i = 1; i <= m; i++) {
    if (a[i - 1] == a[i + 1])
      w[a[i]] += 2;
    else
      w[a[i]]++;
  }
  int ma = 0;
  w[0] = -1;
  for (int i = 1; i <= k; i++)
    if (w[i] > w[ma]) ma = i;
  printf("%d\n", ma);
  return 0;
}
