#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e6 + 7;
const int INF = (int)1e9 + 7;
int n, k;
int a[MAXN], b[MAXN];
int lose[MAXN];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int m = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) b[++m] = a[i];
  }
  for (int i = 1; i <= m; i++) {
    if (i == 1 && i + 1 <= m)
      ++lose[b[i]];
    else if (i == m && i - 1 > 0)
      ++lose[b[i]];
    else if (i > 1 && i < m) {
      lose[b[i]]++;
      if (b[i - 1] == b[i + 1]) lose[b[i]]++;
    }
  }
  int mx = *max_element(lose + 1, lose + k + 1);
  for (int i = 1; i <= k; i++) {
    if (lose[i] == mx) {
      printf("%d", i);
      return 0;
    }
  }
  return 0;
}
