#include <bits/stdc++.h>
using namespace std;
long long a[200000], b[200000];
long long lp[200000];
long long n, k, m, ind, ans, i;
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  a[0] = -1;
  for (i = 0; i < n; i++)
    if (a[i] != a[i + 1]) {
      m++;
      b[m] = a[i + 1];
    }
  for (i = 2; i <= m - 1; i++)
    if (b[i - 1] != b[i + 1])
      lp[b[i]]++;
    else
      lp[b[i]] += 2;
  lp[b[1]]++;
  lp[b[m]]++;
  ans = -1;
  for (i = 1; i <= k; i++)
    if (lp[i] > ans) {
      ans = lp[i];
      ind = i;
    }
  cout << ind << endl;
}
