#include <bits/stdc++.h>
using namespace std;
int n, k, a[100001], x[100001];
int main() {
  memset((x), (0), sizeof((x)));
  cin >> n >> k;
  for (int i = (0); i < ((n)); ++i) {
    cin >> a[i];
    --a[i];
  }
  int res = 0, curr = a[0];
  for (int i = (0); i < ((n)); ++i) {
    if (a[i] != curr) ++res;
    curr = a[i];
  }
  int p = 0;
  while (p < n && a[p] == a[0]) ++p;
  x[a[0]]++;
  x[a[n - 1]]++;
  while (p < n) {
    int s = p;
    while (p < n && a[p] == a[s]) ++p;
    if (p < n) {
      ++x[a[s]];
      if (a[s - 1] == a[p]) ++x[a[s]];
    }
  }
  int mx = x[0], ri = 1;
  for (int i = (0); i < ((k)); ++i)
    if (x[i] > mx) {
      mx = x[i];
      ri = i + 1;
    }
  cout << ri << endl;
  return 0;
}
