#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (v.empty())
      v.push_back(a);
    else {
      if (v.back() == a) continue;
      v.push_back(a);
    }
  }
  vector<long long> vv(k + 1, 1e9);
  for (long long i = 0; i < ((int)(v).size()) - 1; i++) {
    if (v[i] != v[i + 1]) {
      vv[v[i]]--;
      vv[v[i + 1]]--;
    }
  }
  for (long long i = 1; i < ((int)(v).size()) - 1; i++) {
    if (v[i - 1] != v[i + 1]) vv[v[i]]++;
  }
  long long ans = -1;
  long long mn = 1e18;
  for (long long i = 1; i < k + 1; i++) {
    if (vv[i] < mn) {
      ans = i;
      mn = vv[i];
    }
  }
  cout << ans << "\n";
  return 0;
}
