#include <bits/stdc++.h>
using namespace std;
int a[111111], n, k;
pair<int, int> b[111111];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  a[0] = a[1];
  a[n + 1] = a[n];
  for (int i = 1; i <= n;) {
    int j = i;
    while (j + 1 <= n && a[j + 1] == a[i]) ++j;
    int t1 = (a[i] != a[i - 1]) + (a[j] != a[j + 1]);
    int t2 = 0;
    if (i - 1 > 0 && j + 1 <= n) t2 = a[i - 1] != a[j + 1];
    b[a[i]].first += t2 - t1;
    i = j + 1;
  }
  for (int i = (1); i <= (k); ++i) b[i].second = i;
  sort(b + 1, b + k + 1);
  int ans = 2000000000, anss = k + 1;
  for (int i = (k); i >= (1); --i)
    if (b[i].first < ans || b[i].first == ans && b[i].second < anss) {
      ans = b[i].first;
      anss = b[i].second;
    }
  cout << anss;
  return 0;
}
