#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int a[100010];
int cnt[1000010];
vector<int> aa;
int main() {
  int n, k, l, r;
  cin >> n >> k;
  cin >> a[0];
  aa.push_back(a[0]);
  int ind = 0, mx = 100000000, cc = 0;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i - 1] != a[i]) aa.push_back(a[i]);
  }
  for (int i = 0; i + 1 < aa.size(); i++) {
    v[aa[i]].push_back(aa[i + 1]);
    v[aa[i + 1]].push_back(aa[i + 2]);
    cc++;
  }
  for (int i = 0; i + 2 < aa.size(); i++)
    if (aa[i] != aa[i + 2]) cnt[aa[i + 1]]++;
  for (int i = 1; i <= k; i++) {
    if (cc - v[i].size() + cnt[i] < mx) mx = cc - v[i].size() + cnt[i], ind = i;
  }
  cout << ind << endl;
  return 0;
}
