#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i;
  cin >> n >> k;
  int a[n], cnt[100005][2], b, c = 1, minn = 1000000007, ans = 0;
  memset(cnt, 0, sizeof(cnt));
  cin >> a[0];
  for (i = 1; i < n; i++) {
    cin >> b;
    if (b != a[c - 1]) {
      a[c] = b;
      c++;
    }
  }
  for (i = 0; i < c; i++) {
    cnt[a[i]][0]++;
    if (i > 0 && i < n - 1) {
      if (a[i - 1] == a[i + 1]) cnt[a[i]][1]++;
    }
  }
  for (i = 1; i <= k; i++) {
    if (((c - 1) - (cnt[i][0] + cnt[i][1])) < minn) {
      ans = i;
      minn = (c - 1) - (cnt[i][0] + cnt[i][1]);
    }
  }
  cout << ans << endl;
  return 0;
}
