#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, cnt[200005], a[200005], i, j, m, first = 0;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (i != 1 && a[i] != a[i - 1]) first++;
  }
  memset(cnt, 0, sizeof cnt);
  a[0] = a[1];
  a[n + 1] = a[n];
  int l, r;
  for (i = 1; i <= n;) {
    int p = i;
    l = a[i - 1];
    while (p <= n && a[p] == a[i]) {
      p++;
    }
    r = a[p];
    if (l == r)
      cnt[a[i]] += 2;
    else
      cnt[a[i]]++;
    i = p;
  }
  int ans = -1;
  for (i = 1; i <= k; i++) {
    if (ans == -1 || cnt[ans] < cnt[i]) ans = i;
  }
  cout << ans;
  return 0;
}
