#include <bits/stdc++.h>
using namespace std;
int a[100005], n, b[100005], tot[100005], mx[100005];
vector<int> v[100005];
int main() {
  int i, j, k;
  scanf("%d%d", &n, &k);
  for ((i) = 0; (i) < (n); (i)++) {
    scanf("%d", &a[i]);
  }
  tot[0] = 1;
  b[0] = a[0];
  int cnt = 1;
  for (i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      b[cnt] = a[i];
      cnt++;
    }
    tot[cnt - 1]++;
  }
  b[cnt] = -1;
  n = cnt;
  int fmx = -1, smx = -1, mxv = -1;
  for ((i) = 0; (i) < (n); (i)++) {
    if (tot[i] >= fmx && b[i] != mxv) {
      smx = fmx;
      fmx = tot[i];
      mxv = b[i];
    } else if (tot[i] > fmx) {
      fmx = tot[i];
    } else if (tot[i] > smx) {
      smx = tot[i];
    }
  }
  for ((i) = 0; (i) < (n); (i)++) {
    v[b[i] - 1].push_back(i);
  }
  for ((i) = 0; (i) < (k); (i)++) mx[i] = n - 1;
  int pos;
  for ((i) = 0; (i) < (k); (i)++) {
    int prev = -1, tt = 0;
    if (v[i][0]) {
      prev = b[v[i][0] - 1];
    }
    for ((j) = 0; (j) < (v[i].size()); (j)++) {
      pos = v[i][j];
      if (pos && b[pos + 1] == b[pos - 1]) mx[i]--;
      mx[i]--;
    }
  }
  cout << min_element(mx, mx + k) - mx + 1 << endl;
  return 0;
}
