#include <bits/stdc++.h>
using namespace std;
int num[100005];
int hashs[100005] = {0};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  for (int i = 0; i < n;) {
    if (num[i + 1] != num[i]) {
      int j = i + 2;
      while (num[i + 1] == num[j]) j++;
      if (num[i] == num[j])
        hashs[num[i + 1]] += 2;
      else
        hashs[num[i + 1]]++;
      i = j - 1;
    } else
      i++;
  }
  int ans = 1;
  int maxn = 0;
  for (int i = 1; i <= m; i++) {
    if (hashs[i] > maxn) {
      maxn = hashs[i];
      ans = i;
    }
  }
  printf("%d\n", ans);
}
