#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 192;
int a[N], s[N], next[N], pred[N], mx, q, e, v, n, k, d[N], m, b[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> k;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    if (b[i] != b[i - 1]) {
      a[++n] = b[i];
    }
  }
  d[a[1]]++;
  d[a[n]]++;
  for (int i = 2; i < n; i++) {
    if (a[i - 1] == a[i + 1])
      d[a[i]] += 2;
    else
      d[a[i]] += 1;
  }
  for (int i = 1; i <= k; ++i)
    if (d[i] > d[mx]) mx = i;
  cout << mx;
}
