#include <bits/stdc++.h>
using namespace std;
int main() {
  int size;
  cin >> size;
  int numOfK;
  cin >> numOfK;
  vector<int> array(size);
  for (int i = 0; i < size; ++i) {
    int temp;
    cin >> temp;
    array[i] = temp;
  }
  vector<int> stressArray(numOfK, 0);
  if (array[0] != array[1]) {
    stressArray[array[0] - 1] += 1;
  }
  if (array[size - 1] != array[size - 2]) {
    stressArray[array[size - 1] - 1] += 1;
  }
  for (int i = 1; i < size - 1; ++i) {
    if (array[i] != array[i + 1]) {
      stressArray[array[i] - 1] += 1;
      if (array[i + 1] == array[i - 1]) {
        stressArray[array[i] - 1] += 1;
      }
    }
  }
  std::vector<int>::iterator result;
  result = max_element(stressArray.begin(), stressArray.end());
  cout << distance(stressArray.begin(), result) + 1;
  return 0;
}
