#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct coord {
  int l, r;
};
int n, k, i, res, ma, x, j, q, a[N], p[N];
coord c;
vector<coord> b, r[N];
int main() {
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (i = 2; i <= n; ++i) {
    p[i] = p[i - 1];
    if (a[i] != a[i - 1]) p[i]++;
  }
  c.l = 1;
  c.r = 1;
  b.push_back(c);
  ma = -1;
  for (i = 2; i <= n; ++i) {
    if (a[i] == a[i - 1]) {
      b[b.size() - 1].r++;
    } else {
      c.l = i;
      c.r = i;
      b.push_back(c);
    }
  }
  for (i = 0; i < b.size(); ++i) {
    r[a[b[i].l]].push_back(b[i]);
  }
  for (j = 1; j <= k; ++j) {
    res = 0;
    for (i = 1; i < r[j].size(); ++i) {
      res += p[r[j][i].l - 1] - p[r[j][i - 1].r + 1];
    }
    if (r[j][r[j].size() - 1].r + 1 <= n) {
      res += p[n] - p[r[j][r[j].size() - 1].r + 1];
    }
    if (r[j][0].l - 1 >= 0) {
      res += p[r[j][0].l - 1];
    }
    for (i = 0; i < r[j].size(); ++i) {
      if (r[j][i].l - 1 >= 1 && r[j][i].r + 1 <= n) {
        if (a[r[j][i].l - 1] != a[r[j][i].r + 1]) res++;
      }
    }
    if (ma == -1 || ma > res) {
      ma = res;
      x = j;
    }
  }
  cout << x << endl;
  return 0;
}
