#include <bits/stdc++.h>
using namespace std;
int g[100002], p[100002];
int main(int argc, char **argv) {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> g[i];
    if (g[i] == g[i - 1]) {
      --i;
      --n;
    }
  }
  for (int i = 1; i <= k; ++i) p[i] = n - 1;
  for (int i = 1; i <= n; ++i) {
    --p[g[i]];
    if (g[i - 1] == g[i + 1]) --p[g[i]];
  }
  int min = n;
  int res = 0;
  for (int i = 1; i <= k; ++i) {
    if (p[i] < min) {
      min = p[i];
      res = i;
    }
  }
  cout << res << endl;
  return 0;
}
