#include <bits/stdc++.h>
using namespace std;
int min(int x, int y) { return x < y ? x : y; }
int max(int x, int y) { return x > y ? x : y; }
const int N = 100005;
const int M = 2000005;
int num[N], a[N];
int main() {
  int i, j, k, l;
  int n, m, t;
  int x, y, w;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (i = 0, a[n] = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0, j = 0; i < n; i++)
      if (a[i] != a[i + 1]) a[j++] = a[i];
    int Max = -1, ans = 1;
    memset(num, 0, sizeof(num));
    for (i = 0; i < j; i++) {
      num[a[i]]++;
      if (i != 0 && i != j - 1 && a[i - 1] == a[i + 1]) num[a[i]]++;
      if (num[a[i]] > Max || (num[a[i]] == Max && ans > a[i]))
        Max = num[a[i]], ans = a[i];
    }
    printf("%d\n", ans);
  }
  return 0;
}
