#include <bits/stdc++.h>
using namespace std;
int a[100010], n, k;
int num[100010], now, b, e;
int main() {
  scanf("%d%d", &n, &k);
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  b = 0;
  now = a[1];
  a[++n] = 0;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      continue;
    } else {
      e = a[i];
      num[now]++;
      num[now] += e == b;
      b = now;
      now = e;
    }
  }
  int ans = 100010, cnt = 0;
  for (int i = 1; i <= k; i++) {
    if (cnt < num[i]) {
      cnt = num[i];
      ans = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
