#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    vector<int> ve, record;
    for (int i = 1; i <= n; i++) {
      int t;
      scanf("%d", &t);
      if (ve.size() == 0 || ve[ve.size() - 1] != t) ve.push_back(t);
    }
    record.resize(k + 1);
    for (int i = 0; i < ve.size(); i++) {
      record[ve[i]]++;
      if (i - 1 >= 0 && i + 1 < ve.size() && ve[i - 1] == ve[i + 1])
        record[ve[i]]++;
    }
    int turn = ve.size() - 1;
    int ans = 1, mmax = 10000000;
    for (int i = 1; i <= k; i++) {
      int tmp = turn - record[i];
      if (tmp < mmax) {
        ans = i;
        mmax = tmp;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
