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