#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5);
int ans[N + 1], ans_i = 0;
int arr[N], last = 0;
int n, k;
int main(int argc, char *argv[]) {
  memset(ans, 0, sizeof(ans));
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
    if (arr[i] != arr[last]) {
      if (!last) {
        ans[arr[last]]++;
      } else {
        if (arr[last - 1] == arr[i]) {
          ans[arr[last]] += 2;
        } else {
          ans[arr[last]]++;
        }
      }
      last = i;
    }
  }
  ans[arr[last]]++;
  for (int i = 1; i <= k; ++i) {
    if (ans[i] > ans[ans_i]) {
      ans_i = i;
    }
  }
  printf("%d", ans_i);
  return 0;
}
