#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (i != 0) {
      if (v[v.size() - 1] != x) {
        v.push_back(x);
      }
    } else {
      v.push_back(x);
    }
  }
  int m = v.size();
  int arr[k + 1];
  arr[0] = INT_MIN;
  for (int i = 1; i <= k; i++) {
    arr[i] = 0;
  }
  arr[v[0]] += 1;
  arr[v[m - 1]] += 1;
  for (int i = 1; i < m - 1; i++) {
    int a = v[i - 1];
    int b = v[i + 1];
    if (a == b) {
      arr[v[i]] += 2;
    } else {
      arr[v[i]] += 1;
    }
  }
  int mi = INT_MIN;
  int ans = -1;
  for (int i = 1; i <= k; i++) {
    if (mi < arr[i]) {
      mi = arr[i];
      ans = i;
    }
  }
  cout << ans;
}
