#include <bits/stdc++.h>
using namespace std;
int n, k, nb, maxi, pos;
int a[100000], b[100000], stress[100000 + 1];
int main() {
  while (cin >> n >> k) {
    for (int i = 0; i < n; ++i) cin >> a[i];
    memset(stress, 0, sizeof(stress));
    nb = 1;
    b[0] = a[0];
    for (int i = 1; i < n; ++i)
      if (a[i] != b[nb - 1]) b[nb++] = a[i];
    stress[b[0]]++;
    stress[b[nb - 1]]++;
    for (int i = 1; i < nb - 1; ++i)
      if (b[i - 1] == b[i + 1])
        stress[b[i]] += 2;
      else
        stress[b[i]]++;
    maxi = 0;
    for (int i = 1; i <= k; ++i) {
      if (stress[i] > maxi) pos = i, maxi = stress[i];
    }
    cout << pos << endl;
  }
}
