#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int maxn = 100005;
int arr[maxn];
int ans[maxn];
int main() {
  int n, m;
  int i;
  scanf("%d%d", &n, &m);
  int temp, cnt = 0;
  scanf("%d", &arr[++cnt]);
  for (i = 2; i <= n; i++) {
    scanf("%d", &temp);
    if (temp == arr[cnt]) continue;
    arr[++cnt] = temp;
  }
  int res = cnt - 1;
  for (i = 1; i <= cnt; i++) ans[arr[i]] = res;
  for (i = 1; i <= cnt; i++) {
    if (i == 1 || i == cnt) {
      ans[arr[i]]--;
      continue;
    }
    if (arr[i - 1] == arr[i + 1]) {
      ans[arr[i]] -= 2;
    } else
      ans[arr[i]] -= 1;
  }
  int Min = INF;
  for (i = 1; i <= m; i++) {
    if (Min > ans[i]) {
      Min = ans[i];
      res = i;
    }
  }
  printf("%d\n", res);
}
