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