#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int arr[100001];
int cnt[100001];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  v.push_back(arr[0]);
  for (int i = 1; i < n; i++)
    if (arr[i] != v.back()) v.push_back(arr[i]);
  cnt[v[0]]++;
  cnt[v.back()]++;
  for (int i = 1; i < v.size() - 1; i++) {
    if (v[i - 1] == v[i + 1])
      cnt[v[i]] += 2;
    else
      cnt[v[i]]++;
  }
  int best = 0;
  int mx = -1;
  for (int i = 1; i <= k; i++) {
    if (cnt[i] > mx) {
      mx = cnt[i];
      best = i;
    }
  }
  cout << best << endl;
  return 0;
}
