#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int sign(double x) {
  if (x < -eps) return -1;
  return x > eps;
}
struct Tpoint {
  double x, y;
  Tpoint() {}
  Tpoint(double x, double y) : x(x), y(y) {}
  inline double norm() { return sqrt(x * x + y * y); }
  inline void rotate(double ang) {
    double co = cos(ang), si = sin(ang);
    double tx = x, ty = y;
    x = tx * co - ty * si;
    y = tx * si + ty * co;
  }
};
inline Tpoint operator+(const Tpoint &a, const Tpoint &b) {
  return Tpoint(a.x + b.x, a.y + b.y);
}
inline Tpoint operator-(const Tpoint &a, const Tpoint &b) {
  return Tpoint(a.x - b.x, a.y - b.y);
}
inline Tpoint operator*(const Tpoint &a, const double &b) {
  return Tpoint(a.x * b, a.y * b);
}
inline Tpoint operator/(const Tpoint &a, const double &b) {
  return Tpoint(a.x / b, a.y / b);
}
inline double det(const Tpoint &a, const Tpoint &b) {
  return a.x * b.y - a.y * b.x;
}
inline double dot(const Tpoint &a, const Tpoint &b) {
  return a.x * b.x + a.y * b.y;
}
const int maxn = 100005;
int delta[maxn];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a;
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    if (a.size() == 0 || x != a.back()) {
      a.push_back(x);
    }
  }
  int basic = (int)a.size() - 1;
  if (a.size() > 1) {
    ++delta[a[0]];
    ++delta[a[a.size() - 1]];
  }
  for (int i = 1; i + 1 < a.size(); ++i) {
    if (a[i - 1] == a[i + 1]) {
      delta[a[i]] += 2;
    } else {
      delta[a[i]] += 1;
    }
  }
  int ans = 1000000000, choice = 0;
  for (int i = 1; i <= k; ++i) {
    if (ans > basic - delta[i]) {
      ans = basic - delta[i];
      choice = i;
    }
  }
  printf("%d\n", choice);
  return 0;
}
