#include <bits/stdc++.h>
using namespace std;
bool isLow(char ch) {
  if (ch >= 'a' && ch <= 'z') return true;
  return false;
}
bool isUpp(char ch) {
  if (ch >= 'A' && ch <= 'Z') return true;
  return false;
}
bool isDig(char ch) {
  if (ch >= '0' && ch <= '9') return true;
  return false;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> ara;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (ara.size() == 0)
      ara.push_back(x);
    else if (ara.back() != x)
      ara.push_back(x);
  }
  int bra[k + 1];
  memset(bra, 0, sizeof(bra));
  for (int i = 1; i < ara.size() - 1; i++)
    if (ara[i - 1] == ara[i + 1])
      bra[ara[i]] += 2;
    else
      bra[ara[i]]++;
  bra[ara[0]]++;
  bra[ara.back()]++;
  int ans = 0, p;
  for (int i = 1; i <= k; i++)
    if (ans < bra[i]) ans = bra[i], p = i;
  printf("%d\n", p);
  return 0;
}
