#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = 10000000;
int arr[100005];
int st[100005];
int main() {
  int n, k;
  cin >> n >> k;
  int tot = 0;
  cin >> arr[0];
  int nn = 1, x;
  for (int i = (1); i < (n); i++) {
    scanf("%d", &x);
    if (x != arr[nn - 1]) arr[nn++] = x;
    arr[i] = x;
  }
  int ans = 1, mx = -1;
  if (nn == 2) {
    puts("1");
    return 0;
  }
  if (arr[0] != arr[1]) {
    st[arr[0]]++;
  }
  for (int i = (1); i < (nn - 1); i++) {
    if (arr[i - 1] == arr[i + 1] && arr[i] != arr[i - 1]) {
      st[arr[i]] += 2;
    } else
      st[arr[i]]++;
  }
  if (arr[nn - 1] != arr[nn - 2]) {
    st[arr[nn - 1]]++;
  }
  for (int i = (1); i < (k + 1); i++) {
    if (st[i] > mx) {
      mx = st[i];
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
