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