#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
long long int nCrModPFermat(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void SieveOfEratosthenes(long long int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true)
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
  }
  for (long long int p = 2; p <= n; p++)
    if (prime[p]) cout << p << " ";
}
int main() {
  fast();
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int v[n];
    vector<int> a;
    map<int, int> m;
    for (int i = 0; i < n; ++i) cin >> v[i];
    a.push_back(v[0]);
    for (int i = 1; i < n; ++i) {
      if (v[i] != a[a.size() - 1]) a.push_back(v[i]);
    }
    n = a.size();
    m[a[0]]++;
    for (int i = 1; i < n; ++i) {
      if (i < n - 1 && a[i - 1] == a[i + 1])
        m[a[i]] += 2;
      else
        m[a[i]]++;
    }
    int maxi = 0, ans;
    for (auto x : m) {
      if (maxi < x.second) {
        maxi = x.second;
        ans = x.first;
      }
    }
    cout << ans << "\n";
  }
}
