#include <bits/stdc++.h>
using namespace std;
int N, K;
int ar[100004];
int genre[100004];
int exist[100004];
int main() {
  cin >> N >> K;
  int mx = -1;
  int cnt = 0;
  int pre = -1;
  for (int i = 0; i < N; i++) {
    int cur;
    cin >> cur;
    mx = max(mx, cur);
    if (pre != cur) {
      ar[++cnt] = cur;
      exist[cur] = 1;
    }
    pre = cur;
  }
  N = cnt;
  ar[0] = ar[2];
  ar[N + 1] = ar[N - 1];
  int tot = 0;
  for (int i = 1; i <= cnt; i++) {
    if (i != 1 && i != N)
      if (ar[i - 1] != ar[i + 1]) genre[ar[i]]--;
    if (i != 1) genre[ar[i]]++;
    if (i != N) genre[ar[i]]++;
  }
  int curmx = -1, ind;
  for (int i = 1; i <= K; i++) {
    if (exist[i] == 0) continue;
    if (genre[i] > curmx) {
      curmx = genre[i];
      ind = i;
    }
  }
  cout << ind << endl;
  return 0;
}
