#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int a[maxn];
int c[maxn];
int main() {
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i != 1)
      if (a[i] != a[i - 1]) cnt++;
  }
  a[0] = a[1];
  a[n + 1] = a[n];
  for (int j = 1; j <= n; j++) {
    int z = a[j];
    int second = j;
    while (a[j] == z) {
      j++;
    }
    if (second == 1 || j == n + 1) {
      c[z]++;
    } else if (a[j] == a[second - 1]) {
      c[z] += 2;
    } else if (a[j] != a[second - 1])
      c[z]++;
    j--;
  }
  int ans = 0;
  int www = 0;
  for (int i = 1; i <= k; i++) {
    if (c[i] > ans) {
      www = i;
      ans = c[i];
    }
  }
  cout << www;
}
