#include <bits/stdc++.h>
using namespace std;
int stress[100001];
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  vector<int> v;
  cin >> a[0];
  v.push_back(a[0]);
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] != a[i - 1]) {
      v.push_back(a[i]);
    }
  }
  for (int i = 0; i < 100001; i++) {
    stress[i] = -1;
  }
  stress[v[0]]++;
  stress[v.back()]++;
  for (int i = 1; i < (int)v.size() - 1; i++) {
    if (v[i - 1] == v[i + 1]) {
      stress[v[i]] += 2;
    } else {
      stress[v[i]]++;
    }
  }
  int maxzn = -1, zap = 0;
  for (int i = 1; i < 100001; i++) {
    if (stress[i] > maxzn) {
      zap = i;
      maxzn = stress[i];
    }
  }
  cout << zap << endl;
  return 0;
}
