#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, k, a[MAXN];
int cnt[MAXN];
vector<int> bls;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    bls.push_back(a[i]);
    while (a[i] == a[i + 1]) i++;
  }
  cnt[bls[0]]++;
  cnt[bls[bls.size() - 1]]++;
  for (int i = 1; i < (int)bls.size() - 1; i++) {
    if (bls[i - 1] == bls[i + 1]) cnt[bls[i]]++;
    cnt[bls[i]]++;
  }
  int mx = 0, ans = 0;
  for (int i = 1; i <= k; i++) {
    if (mx < cnt[i]) {
      mx = cnt[i];
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
