#include <bits/stdc++.h>
using namespace std;
vector<int> l[100000 + 10];
int arr[100000 + 10];
int v[100000 + 10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N, k;
  cin >> N >> k;
  for (int i = 1; i <= N; i++) cin >> arr[i];
  v[1] = arr[1];
  int n = 1;
  for (int i = 2; i <= N; i++) {
    if (arr[i] == v[n]) continue;
    v[++n] = arr[i];
  }
  for (int i = 1; i <= n; i++) l[v[i]].push_back(i);
  int ans = -1;
  int lowest = 1000000;
  for (int i = 1; i <= k; i++) {
    int cnt = n;
    for (auto j : l[i]) {
      if (v[j - 1] == v[j + 1])
        cnt = cnt - 2;
      else
        cnt = cnt - 1;
    }
    if (cnt < lowest) {
      ans = i;
      lowest = cnt;
    }
  }
  cout << ans << endl;
}
