Problem: The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are n gems in the Shuseki Islands in total, and the i-th gem is located on island pi.

Mr. Kitayuta has just arrived at island 0. With his great jumping ability, he will repeatedly perform jumps between islands to the east according to the following process: 

  * First, he will jump from island 0 to island d. 
  * After that, he will continue jumping according to the following rule. Let l be the length of the previous jump, that is, if his previous jump was from island prev to island cur, let l = cur - prev. He will perform a jump of length l - 1, l or l + 1 to the east. That is, he will jump to island (cur + l - 1), (cur + l) or (cur + l + 1) (if they exist). The length of a jump must be positive, that is, he cannot perform a jump of length 0 when l = 1. If there is no valid destination, he will stop jumping. 



Mr. Kitayuta will collect the gems on the islands visited during the process. Find the maximum number of gems that he can collect.

Input

The first line of the input contains two space-separated integers n and d (1 ≤ n, d ≤ 30000), denoting the number of the gems in the Shuseki Islands and the length of the Mr. Kitayuta's first jump, respectively.

The next n lines describe the location of the gems. The i-th of them (1 ≤ i ≤ n) contains a integer pi (d ≤ p1 ≤ p2 ≤ ... ≤ pn ≤ 30000), denoting the number of the island that contains the i-th gem.

Output

Print the maximum number of gems that Mr. Kitayuta can collect.

Examples

Input

4 10
10
21
27
27


Output

3


Input

8 8
9
19
28
36
45
55
66
78


Output

6


Input

13 7
8
8
9
16
17
17
18
21
23
24
24
26
30


Output

4

Note

In the first sample, the optimal route is 0  →  10 (+1 gem)  →  19  →  27 (+2 gems)  → ...

In the second sample, the optimal route is 0  →  8  →  15  →  21 →  28 (+1 gem)  →  36 (+1 gem)  →  45 (+1 gem)  →  55 (+1 gem)  →  66 (+1 gem)  →  78 (+1 gem)  → ...

In the third sample, the optimal route is 0  →  7  →  13  →  18 (+1 gem)  →  24 (+2 gems)  →  30 (+1 gem)  → ...

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000000000000000000;
long long mod = 1000000000;
long double pi = 3.141592653589793238;
void pls() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long mul_mod(long long a, long long b, long long m) {
  long long x = 0, y = a;
  while (b > 0) {
    if (b & 1) {
      x = (x + y) % m;
    }
    y = (y + y) % m;
    b >>= 1;
  }
  return x;
}
inline long long modu(long long val, long long modul) {
  return (val % modul + modul) % modul;
}
inline int madd(int x, int y) { return (x % mod + y % mod) % mod; }
inline int msub(int x, int y) { return (mod + x % mod - y % mod) % mod; }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long powmod(long long a, long long mod, long long p) {
  if (p == 0) return 1;
  long long res;
  long long x = powmod(a, mod, p / 2);
  res = x;
  if (p & 1) x = mul_mod(x, a, mod);
  return mul_mod(x, res, mod);
}
long long exp(long long a, long long p) {
  if (p == 0) return 1;
  long long res;
  long long x = exp(a, p / 2);
  res = x;
  if (p & 1) x = (x * a);
  return (x * res);
}
long long sqt(long long x) {
  long long l = 1LL;
  long long r = x;
  long long res;
  while (l <= r) {
    long long mid = l + (r - l) / 2;
    if (mid * mid <= x) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return res;
}
bool isprime(long long n) {
  for (int i = 2; i <= sqt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
vector<int> soe(long long upto) {
  vector<bool> prime(upto + 1, 0);
  prime[1] = 1;
  prime[0] = 1;
  for (int i = 2; i <= sqt(upto); i++) {
    if (!prime[i]) {
      for (int j = 2 * i; j <= upto; j += i) prime[j] = 1;
    }
  }
  vector<int> res;
  res.push_back(2);
  for (int i = 3; i < prime.size(); i += 2) {
    if (!prime[i]) res.push_back(i);
  }
  return res;
}
int di[8] = {-1, -1, -1, 1, 1, 1, 0, 0};
int dj[8] = {-1, 0, 1, -1, 0, 1, -1, 1};
int ii[4] = {0, 0, -1, 1};
int jj[4] = {-1, 1, 0, 0};
long long n, d;
long long a[30001];
long long ex;
long long dp[500][30001];
long long top_down(int ix, int pre) {
  if (ix > 30000) return 0;
  if (dp[pre][ix] != -1) return dp[pre][ix];
  long long previous = d + (pre - 250);
  long long p = 0, q = 0, r = 0;
  if (previous > 0) p = top_down(ix + previous, pre);
  if (previous > 1) q = top_down(ix + previous - 1, pre - 1);
  r = top_down(ix + previous + 1, pre + 1);
  return dp[pre][ix] = a[ix] + max({p, q, r});
}
void solve() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a[x] += 1;
  }
  memset(dp, -1, sizeof(dp));
  cout << top_down(d, 250) << endl;
}
int main() {
  pls();
  solve();
  return 0;
}