#include<bits/stdc++.h>
using namespace std;
#define NAME "TEST"
#define nl '\n'
#define allofa(x,sz) x+1,x+sz+1
#define allof(x) x.begin(),x.end()
#define mset(x,val) memset(x,val,sizeof(x))
template<typename T> T Max(T x, T y){return(x>y)?x:y;};
template<typename T> T Min(T x, T y){return(x<y)?x:y;};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b){a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b){a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e18;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
int a[MAXN];
int n,x;
void ccps() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(NAME".inp","r")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
}
struct FenwickTree {
int n;
vector<int> fen;
FenwickTree(int N = 0) {
n=N;if(n>0) {
fen.assign(n+4,0);
}
}
void update(int node, int val) {
while(node<=n) {
maximize(fen[node],val);
node+=(node & -node);
}
}
int getVal(int node) {
int res = 0;
while(node>0) {
maximize(res,fen[node]);
node-=(node & -node);
}
return res;
}
} fen,flis,flds;
namespace sub2 {
bool check() {
return n<=50 and x<=50 and x!=0;
}
void sol() {
int b[n+5],dp[n+5];
vector<int> comp;
int res = 1;
for (int d = -x; d<=x; d++) {
for (int l = 1; l<=n; l++) {
for (int r = l; r<=n; r++) {
for (int i = 1; i<=n; i++) {
b[i]=a[i];
dp[i]=0;
}
for (int i = l; i<=r; i++) {
b[i]+=d;
}
int curLIS = 1;
comp.clear();
for (int i = 1; i<=n; i++) {
comp.push_back(b[i]);
}
sort(allof(comp));
comp.resize(unique(allof(comp))-comp.begin());
fen = FenwickTree((int)comp.size());
for (int i = 1; i<=n; i++) {
int pos = lower_bound(allof(comp),b[i])-comp.begin()+1;
dp[i] = fen.getVal(pos-1)+1;
fen.update(pos,dp[i]);
maximize(curLIS,dp[i]);
}
maximize(res,curLIS);
}
}
}
cout << res;
}
}
namespace sub3 {
const int N = 1010;
int b[N][N];
bool check() {
return n<=1000;
}
void sol() {
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=n; j++) {
b[i][j] = a[j];
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=i; j++) {
b[i][j]-=x;
}
}
int res = 1;
for (int i = 1; i<=n; i++) {
vector<int> comp;
vector<int> dp(n+1,0);
for (int j = 1; j<=n; j++) {
comp.push_back(b[i][j]);
}
sort(allof(comp));
comp.resize(unique(allof(comp))-comp.begin());
fen = FenwickTree((int)comp.size());
int curLis = 1;
for (int j = 1; j<=n; j++) {
int pos = lower_bound(allof(comp),b[i][j])-comp.begin()+1;
dp[j] = fen.getVal(pos-1)+1;
fen.update(pos,dp[j]);
maximize(curLis,dp[j]);
}
maximize(res,curLis);
}
cout << res;
}
}
namespace sub4 {
ll dp[MAXN];
bool check() {
return x==0;
}
void sol() {
vector<int> comp;
fill(allofa(dp,n),0);
for (int i = 1; i<=n; i++) {
comp.push_back(a[i]);
}
sort(allof(comp));
comp.resize(unique(allof(comp))-comp.begin());
fen = FenwickTree((int)comp.size());
int res = 1;
for (int i = 1; i<=n; i++) {
int pos = lower_bound(allof(comp),a[i])-comp.begin()+1;
dp[i] = fen.getVal(pos-1)+1;
fen.update(pos,dp[i]);
maximize(res,dp[i]);
}
cout << res;
}
}
signed main() {
ccps();
cin >> n >> x;
for (int i = 1; i<=n; i++) {
cin >> a[i];
}
if(sub2::check()) return sub2::sol(),0;
else if(sub3::check()) return sub3::sol(),0;
else if(sub4::check()) return sub4::sol(),0;
}