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