#include <bits/stdc++.h>
using namespace std;
int a[112345];
int b[112345];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int p = 0, t = -159753;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + p);
    if (a[p] != t) {
      t = a[p];
      ++p;
    }
  }
  b[a[0]]++;
  b[a[p - 1]]++;
  for (int i = 1; i < p - 1; ++i) {
    if (a[i - 1] == a[i + 1]) b[a[i]]++;
    b[a[i]]++;
  }
  int sit;
  int mx = 0;
  for (int i = 1; i <= k; ++i) {
    if (mx < b[i]) {
      mx = b[i];
      sit = i;
    }
  }
  cout << sit << endl;
}
