#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int x;
  scanf("%d", &x);
  vector<int> V;
  int arr[100005] = {};
  for (int i = 1; i < n; ++i) {
    int y;
    scanf("%d", &y);
    if (y != x) {
      V.push_back(x);
      ++arr[x];
      x = y;
    }
  }
  V.push_back(x);
  ++arr[x];
  for (int i = 1; i <= k; ++i) arr[i] = n - arr[i] - 1;
  int sz = V.size();
  for (int i = 1; i < sz - 1; ++i) {
    if (V[i - 1] == V[i + 1]) --arr[V[i]];
  }
  int mini = 1000000000, best = -1;
  for (int i = 1; i <= k; ++i) {
    if (mini > arr[i]) {
      mini = arr[i];
      best = i;
    }
  }
  printf("%d\n", best);
  return 0;
}
