#include <bits/stdc++.h>
using namespace std;
int ri() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int ret = 0;
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return ret;
}
const int maxn = 1e5 + 5;
int n, k, x;
vector<int> a, A;
int cnt[maxn];
int main() {
  int pr = 0;
  n = ri();
  k = ri();
  for (int i = (0); i < (n); ++i) {
    x = ri();
    if (x != pr) {
      pr = x;
      a.push_back(x);
    }
  }
  for (int i = (0); i < (a.size()); ++i) {
    if ((i - 1 >= 0 && i + 1 < a.size()) && a[i - 1] == a[i + 1]) {
      cnt[a[i]] += 2;
    } else
      cnt[a[i]]++;
  }
  int mx = -1, pos = -1;
  for (int i = (1); i < (k + 1); ++i) {
    if (cnt[i] > mx) {
      mx = cnt[i];
      pos = i;
    }
  }
  cout << pos;
}
