#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x, y = -1;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x != y) a.push_back(x - 1);
    y = x;
  }
  vector<int> v(k, 0);
  for (int i = 0; i < a.size(); ++i) {
    if (i == 0 || i == a.size() - 1) {
      ++v[a[i]];
    } else {
      ++v[a[i]];
      if (a[i - 1] == a[i + 1]) ++v[a[i]];
    }
  }
  int mx = 0, ans = 0;
  for (int i = 0; i < k; ++i) {
    if (v[i] > mx) {
      mx = v[i];
      ans = i;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
