#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    --b;
    if (a.size() == 0)
      a.assign(2, b);
    else if (a.back() != b)
      a.push_back(b);
  }
  a.push_back(a.back());
  n = a.size() - 2;
  vector<int> x(k);
  for (int i = 1; i <= n; ++i) {
    if (a[i - 1] == a[i + 1])
      x[a[i]] += 2;
    else
      ++x[a[i]];
  }
  int ret = max_element(x.begin(), x.end()) - x.begin() + 1;
  cout << ret << endl;
  return 0;
}
