#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
map<int, vector<int>> mp;
int c;
vector<int> vis(500005);
int search(int l, int r) {
  int low = 0, high = mp[c].size() - 1;
  int left = -1, right = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] < r) {
      right = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  low = 0;
  high = mp[c].size() - 1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] > l) {
      left = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (left == -1) {
    return 0;
  }
  if (right == -1) {
    return 0;
  }
  int res = max(0, right - left + 1);
  return res;
}
int findl(int l) {
  int low = 0, high = mp[c].size() - 1, ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] < l) {
      ans = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return ans + 1;
}
int findr(int r) {
  int low = 0, high = mp[c].size() - 1, ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] > r) {
      ans = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (ans == -1) {
    return 0;
  }
  return (int)mp[c].size() - ans;
}
void solve(int tt) {
  int n;
  cin >> n >> c;
  vector<int> arr(n), uniq;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i]].push_back(i);
    if (vis[arr[i]] == 0) {
      uniq.push_back(arr[i]);
      vis[arr[i]] = 1;
    }
  }
  int res = mp[c].size(), m = uniq.size();
  for (int i = 0; i < m; i++) {
    int k = mp[uniq[i]].size();
    vector<pair<int, int>> vp;
    for (int j = 0; j < k; j++) {
      vp.push_back({1, mp[uniq[i]][j]});
      if (j + 1 < k) {
        int bet = search(mp[uniq[i]][j], mp[uniq[i]][j + 1]);
        vp.push_back({-bet, -1});
      }
    }
    int tot = 0, ans = 0, l = 0, r = 0, le = 0, ri = 0;
    int lmax = -1, rmax = -1, reml = -1, remr = -1;
    k = vp.size();
    int nums = 0, add = 0;
    for (int j = 0; j < k; j++) {
      if (tot + vp[j].first < 0) {
        tot = 0;
        nums = 0;
        continue;
      } else {
        if (tot == 0) {
          l = vp[j].second;
          le = j;
        }
        tot += vp[j].first;
        r = vp[j].second;
        ri = j;
        if (tot > ans) {
          add = max(add, nums);
          ans = tot;
          lmax = l;
          reml = le;
          rmax = r;
          remr = ri;
        }
      }
    }
    for (int j = reml; j <= remr; j++) {
      if (vp[j].first == 1) {
        add += 1;
      }
    }
    int addl = findl(lmax), addr = findr(rmax);
    int cnt = addl + addr + add;
    res = max(res, cnt);
  }
  cout << res << endl;
  return;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  for (int tt = 0; tt < t; tt++) {
    solve(tt);
  }
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given array a of length n. You can choose one segment [l, r] (1 ≤ l ≤ r ≤ n) and integer value k (positive, negative or even zero) and change a_l, a_{l + 1}, ..., a_r by k each (i.e. a_i := a_i + k for each l ≤ i ≤ r).

What is the maximum possible number of elements with value c that can be obtained after one such operation?

Input

The first line contains two integers n and c (1 ≤ n ≤ 5 ⋅ 10^5, 1 ≤ c ≤ 5 ⋅ 10^5) — the length of array and the value c to obtain.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 5 ⋅ 10^5) — array a.

Output

Print one integer — the maximum possible number of elements with value c which can be obtained after performing operation described above.

Examples

Input


6 9
9 9 9 9 9 9


Output


6


Input


3 2
6 2 6


Output


2

Note

In the first example we can choose any segment and k = 0. The array will stay same.

In the second example we can choose segment [1, 3] and k = -4. The array will become [2, -2, 2].

### Response

```cpp
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
map<int, vector<int>> mp;
int c;
vector<int> vis(500005);
int search(int l, int r) {
  int low = 0, high = mp[c].size() - 1;
  int left = -1, right = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] < r) {
      right = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  low = 0;
  high = mp[c].size() - 1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] > l) {
      left = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (left == -1) {
    return 0;
  }
  if (right == -1) {
    return 0;
  }
  int res = max(0, right - left + 1);
  return res;
}
int findl(int l) {
  int low = 0, high = mp[c].size() - 1, ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] < l) {
      ans = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return ans + 1;
}
int findr(int r) {
  int low = 0, high = mp[c].size() - 1, ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (mp[c][mid] > r) {
      ans = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (ans == -1) {
    return 0;
  }
  return (int)mp[c].size() - ans;
}
void solve(int tt) {
  int n;
  cin >> n >> c;
  vector<int> arr(n), uniq;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i]].push_back(i);
    if (vis[arr[i]] == 0) {
      uniq.push_back(arr[i]);
      vis[arr[i]] = 1;
    }
  }
  int res = mp[c].size(), m = uniq.size();
  for (int i = 0; i < m; i++) {
    int k = mp[uniq[i]].size();
    vector<pair<int, int>> vp;
    for (int j = 0; j < k; j++) {
      vp.push_back({1, mp[uniq[i]][j]});
      if (j + 1 < k) {
        int bet = search(mp[uniq[i]][j], mp[uniq[i]][j + 1]);
        vp.push_back({-bet, -1});
      }
    }
    int tot = 0, ans = 0, l = 0, r = 0, le = 0, ri = 0;
    int lmax = -1, rmax = -1, reml = -1, remr = -1;
    k = vp.size();
    int nums = 0, add = 0;
    for (int j = 0; j < k; j++) {
      if (tot + vp[j].first < 0) {
        tot = 0;
        nums = 0;
        continue;
      } else {
        if (tot == 0) {
          l = vp[j].second;
          le = j;
        }
        tot += vp[j].first;
        r = vp[j].second;
        ri = j;
        if (tot > ans) {
          add = max(add, nums);
          ans = tot;
          lmax = l;
          reml = le;
          rmax = r;
          remr = ri;
        }
      }
    }
    for (int j = reml; j <= remr; j++) {
      if (vp[j].first == 1) {
        add += 1;
      }
    }
    int addl = findl(lmax), addr = findr(rmax);
    int cnt = addl + addr + add;
    res = max(res, cnt);
  }
  cout << res << endl;
  return;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  for (int tt = 0; tt < t; tt++) {
    solve(tt);
  }
  return 0;
}

```