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