#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int n1[100000];
  for (int i = 0; i < k + 1; i++) n1[i] = 0;
  int temp;
  int curr = 0;
  int prev = 0;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp != curr) {
      if (temp == prev) n1[curr]--;
      n1[temp]--;
      prev = curr;
      curr = temp;
    }
  }
  int min = n + 1;
  int index = 0;
  for (int i = 1; i < k + 1; i++) {
    if (n1[i] < min) {
      min = n1[i];
      index = i;
    }
  }
  cout << index;
}
