#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
int n, k;
int a[maxn];
vector<int> ds[maxn];
int stress;
int stmin, res;
void process();
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    ds[a[i]].push_back(i);
  }
  process();
}
void process() {
  for (int i = 1; i <= n - 1; ++i)
    if (a[i] != a[i + 1]) stress++;
  stmin = stress;
  for (int i = 1; i <= k; ++i) {
    int st = stress;
    int tt = ds[i][0], t = ds[i][0], t1;
    for (int j = 1; j <= ds[i].size() - 1; ++j) {
      t = ds[i][j];
      t1 = ds[i][j - 1];
      if (t == t1 + 1) continue;
      st -= 2;
      if (tt == 1 || a[tt - 1] != a[t1 + 1]) st += 1;
      tt = t;
    }
    if (t == n || a[tt - 1] != a[t + 1])
      st -= 1;
    else
      st -= 2;
    if (st < stmin) {
      stmin = st;
      res = i;
    }
  }
  printf("%d\n", res);
}
