#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int flag, ans[100100];
int tmp, ac;
struct Node {
  int id, x;
} haha[100100];
void work() {
  for (int i = 1; i <= m; i++) {
    if (i == 1 || i == m)
      haha[ans[i]].x++;
    else {
      haha[ans[i]].x++;
      if (ans[i - 1] == ans[i + 1]) haha[ans[i]].x++;
    }
  }
  return;
}
bool cmp(Node a, Node b) {
  if (a.x == b.x)
    return a.id < b.id;
  else
    return a.x > b.x;
}
int main() {
  flag = 0;
  while (~scanf("%d%d", &n, &k)) {
    m = 0;
    tmp = 0;
    memset(haha, 0, sizeof(haha));
    for (int i = 1; i <= n; i++) haha[i].id = i;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &flag);
      if (flag != ans[m]) {
        ans[++m] = flag;
      }
    }
    work();
    sort(haha + 1, haha + n + 1, cmp);
    printf("%d\n", haha[1].id);
  }
  return 0;
}
