#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
int a[200000];
int s[200000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  n = unique(a, a + n) - a;
  s[a[0]]++;
  s[a[n - 1]]++;
  for (int i = 1; i < n - 1; ++i) {
    if (a[i - 1] == a[i + 1])
      s[a[i]] += 2;
    else
      s[a[i]]++;
  }
  int b = 1;
  for (int i = 1; i <= k; ++i)
    if (s[i] > s[b]) b = i;
  cout << b;
}
