#include <bits/stdc++.h>
using namespace std;
int a[100005], dp[100005];
int main() {
  int n, m, i, j, k;
  scanf("%d%d", &n, &k);
  scanf("%d", &a[0]);
  int count = 1;
  for (i = 1; i < n; i++) {
    scanf("%d", &m);
    if (m != a[count - 1]) a[count++] = m;
  }
  if (count == 2) {
    printf("%d\n", min(a[0], a[1]));
  } else {
    memset(dp, 0, sizeof(dp));
    dp[a[0]]--;
    dp[a[count - 1]]--;
    for (i = 1; i < count - 1; i++)
      if (a[i - 1] != a[i + 1])
        dp[a[i]]--;
      else if (a[i - 1] == a[i + 1])
        dp[a[i]] -= 2;
    int mm = 0, tt = 1;
    for (i = 1; i <= k; i++)
      if (dp[i] < mm) {
        mm = dp[i];
        tt = i;
      }
    printf("%d\n", tt);
  }
}
