#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 10;
const double eps = 1e-10;
const double PI = acos(-1.0);
int a[MAX], b[MAX];
int main() {
  int n, m, cnt = 0, x;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (!i || x != a[cnt - 1]) a[cnt++] = x;
  }
  memset(b, 0, sizeof(b));
  for (int i = 0; i < cnt; ++i) {
    b[a[i]]++;
    if (i != 0 && i != cnt && a[i - 1] == a[i + 1]) b[a[i]]++;
  }
  int ans = 1;
  for (int i = 2; i <= m; ++i)
    if (b[i] > b[ans]) ans = i;
  printf("%d\n", ans);
  return 0;
}
