#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  cin >> num;
  int k = 0;
  cin >> k;
  vector<int> mx;
  vector<int> temp;
  vector<int> nums;
  for (int i = 0; i <= num; i++) {
    mx.push_back(1);
  }
  for (int i = 0; i < num; i++) {
    int op = 0;
    cin >> op;
    nums.push_back(op);
  }
  for (int i = 0; i < num; i++) {
    int now = 0;
    cin >> now;
    for (int j = i + 1; j < num; j++) {
      if (abs(nums[i] - nums[j]) <= k) {
        mx[j] = max(mx[j], mx[i] + 1);
      }
    }
  }
  cout << mx.back();
  return 0;
}
