#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long b[k];
  cin >> a[0];
  long long size = 1;
  for (long long i = 1; i <= k; i++) b[i] = 0;
  for (long long i = 1; i < n; i++) {
    long long z;
    cin >> a[size];
    size++;
    if (a[size - 2] == a[size - 1]) {
      a[size - 1] = 0;
      size--;
    }
  }
  b[a[0]]++;
  for (int i = 1; i < size - 1; i++) {
    if (a[i - 1] == a[i + 1]) {
      b[a[i]] += 2;
    } else {
      b[a[i]]++;
    }
  }
  b[a[size - 1]]++;
  long long imx = 1, mx = -100;
  for (long long i = 1; i <= k; i++) {
    if (b[i] > mx) {
      mx = b[i];
      imx = i;
    }
  }
  cout << imx;
}
