#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  int a[100005], j = 0, num[100005] = {0};
  cin >> n >> k;
  int p = -1;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x != p) {
      a[++j] = x;
      p = x;
    }
  }
  a[0] = -1;
  a[j + 1] = -1;
  for (int i = 1; i <= j; ++i)
    if (a[i - 1] != a[i + 1])
      num[a[i]]++;
    else
      num[a[i]] += 2;
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    if (num[i] > ans) {
      ans = num[i];
      p = i;
    }
  }
  cout << p << endl;
  return 0;
}
