#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, K;
int tot, bad[MAX], A[MAX];
int main() {
  cin >> N >> K;
  int last = 0;
  tot = 0;
  memset(bad, 0, sizeof(bad));
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] != A[i - 1]) {
      if (i > 0) assert(A[i - 1] == A[last]);
      if (last != 0) {
        if (A[last - 1] == A[i]) {
          bad[A[i - 1]] += 2;
        } else {
          bad[A[i - 1]] += 1;
        }
      } else {
        bad[A[i - 1]] += 1;
      }
      last = i;
      tot++;
    }
  }
  if (last != 0) {
    bad[A[N - 1]] += 1;
  }
  int best = 0, id = -1;
  for (int i = 1; i <= K; i++) {
    if (best < bad[i]) {
      best = bad[i];
      id = i;
    }
  }
  cout << id << endl;
}
