#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 200009;
int n, m, a[MAXN], b[MAXN], c[MAXN];
int main() {
  memset(c, 0, sizeof(c));
  scanf("%d%d", &n, &m);
  int sum = 0, top = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  b[++top] = a[1];
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1]) continue;
    b[++top] = a[i];
    sum++;
  }
  if (top == 1) return 0 * printf("%d\n", b[1]);
  if (top == 2) return 0 * printf("%d\n", min(b[1], b[2]));
  if (b[1] != b[2]) c[b[1]]++;
  if (b[top] != b[top - 1]) c[b[top]]++;
  for (int i = 2; i < top; i++) {
    if (b[i - 1] == b[i + 1])
      c[b[i]] += 2;
    else
      c[b[i]]++;
  }
  int maxa = sum, ans = 1;
  for (int i = 1; i <= m; i++) {
    if (sum - c[i] < maxa) {
      maxa = sum - c[i];
      ans = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
