#include <bits/stdc++.h>
using namespace std;
int id[110001];
int ans[1000001];
int main() {
  int n, m, i, number, t;
  while (scanf("%d %d", &n, &m) != EOF) {
    number = 0;
    memset(id, 0, sizeof(id));
    memset(ans, 0, sizeof(ans));
    for (i = 0; i < n; i++) {
      scanf("%d", &t);
      if (!i)
        id[number++] = t;
      else if (id[number - 1] != t)
        id[number++] = t;
    }
    for (i = 0; i < number; i++) {
      if (i == 0 || i == number - 1)
        ans[id[i]]++;
      else if (id[i - 1] == id[i + 1])
        ans[id[i]] += 2;
      else
        ans[id[i]] += 1;
    }
    int sum = 0, h = 0;
    for (i = 1; i <= m; i++) {
      if (ans[i] > sum) {
        sum = ans[i];
        h = i;
      }
    }
    printf("%d\n", h);
  }
  return 0;
}
