#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> compress;
  vector<int> v;
  v.resize(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int ptr = 0;
  while (ptr < n) {
    int curr = v[ptr];
    ptr++;
    while (ptr < n && v[ptr] == curr) ++ptr;
    compress.push_back(curr);
  }
  int freq[100001];
  memset(freq, 0, sizeof(freq));
  ;
  int sz = ((int)(compress.size()));
  for (int j = 1; j < sz - 1; ++j) {
    if (compress[j - 1] == compress[j + 1] && compress[j] != compress[j - 1])
      freq[compress[j]]++;
    freq[compress[j]]++;
  }
  freq[compress[0]]++;
  freq[compress[sz - 1]]++;
  int best = 0;
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    if (best < freq[i]) {
      best = freq[i];
      ans = i;
    }
  }
  cout << ans;
}
