#include <bits/stdc++.h>
using namespace std;
const long long Long_max = numeric_limits<long long>::max();
const int Int_max = numeric_limits<int>::max();
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
int dy[] = {0, 0, -1, 1, 1, -1, 1, -1};
void File_input(string pathIn) { freopen(pathIn.c_str(), "r", stdin); }
void File_output(string pathOut) { freopen(pathOut.c_str(), "w", stdout); }
int msg() {
  srand(time(0));
  vector<string> st = {"Wish everyone high ratings!", "Good luck!", "Have fun!",
                       "Please, read all the problems!", "Go Go fight!"};
  cerr << st[rand() % (int)st.size()];
  return 0;
}
void FastInputOutput() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int n, k;
bool valid(int x) { return x >= 0 && x < n; }
int v;
int main() {
  FastInputOutput();
  cin >> n >> k;
  vector<int> frq(k + 5, 0), a(n + 1);
  int idx = 0;
  int last = -1;
  for (int i = 0; i < n; i++) {
    cin >> v;
    if (v != last) a[idx++] = v;
    last = v;
  }
  for (int i = 0; i < idx; i++) {
    if (i == 0 || i == idx - 1) {
      frq[a[i]]++;
    } else {
      if (a[i - 1] == a[i + 1]) {
        frq[a[i]] += 2;
      } else
        frq[a[i]]++;
    }
  }
  int val = 1;
  for (int i = 1; i <= k; i++) {
    if (frq[i] > frq[val]) val = i;
  }
  cout << val;
}
