#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt, f;
void solve() {
  int n, c, ans = 0;
  cin >> n >> c;
  for (int(i) = 0; (i) < (n); ++(i)) {
    int a;
    cin >> a;
    a -= c;
    ++cnt[a];
    if (!a) continue;
    int cur = cnt[a] - cnt[0];
    if (!f.count(a)) f[a] = cur;
    f[a] = min(f[a], cur);
    cur = max(cur, cur - f[a] + 1);
    ans = max(ans, cur);
  }
  cout << cnt[0] + ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
