#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const int Max = 110000;
int maxz(int x, int y) { return x > y ? x : y; }
int minz(int x, int y) { return x < y ? x : y; }
int a[123456];
int b[123456];
int num[123456];
int main() {
  int T, n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  int u = 1;
  for (i = 1; i < n; i++)
    if (a[i] != a[i - 1]) a[u++] = a[i];
  num[a[0]] = 1;
  for (i = 1; i < u - 1; i++) {
    num[a[i]]++;
    if (a[i - 1] == a[i + 1]) b[a[i]]++;
  }
  num[a[i]]++;
  int minn = 123456;
  int k = 0;
  for (i = 1; i <= m; i++)
    if (u - 1 - num[i] - b[i] < minn) {
      minn = u - 1 - num[i] - b[i];
      k = i;
    }
  printf("%d\n", k);
  return 0;
}
