#include <iostream>
#include <vector>
#include <cmath>
std::vector<std::vector<int>> get_sub_tables(std::vector<int>& table, int difference)
{
std::vector<std::vector<std::vector<int>::iterator>> i_sub_tables;
std::vector<std::vector<int>> sub_tables;
for (auto element = table.begin(); element != table.end(); ++element)
{
std::vector<std::vector<int>::iterator> temp;
temp.emplace_back(element);
i_sub_tables.emplace_back(temp);
}
for (auto start_e = table.begin(); start_e != table.end(); ++start_e)
{
auto min = start_e;
for (auto cur_e = start_e + 1; cur_e != table.end(); ++cur_e)
{
int res = *min - *cur_e;
if (std::abs(res) <= difference)
{
std::vector<std::vector<int>::iterator> temp;
for (auto i = start_e; i != cur_e + 1; ++i)
{
temp.emplace_back(i);
}
i_sub_tables.emplace_back(temp);
}
else
{
break;
}
}
}
int counter = 0;
for (auto table_of_i : i_sub_tables)
{
auto element_loc = std::find(i_sub_tables.begin(), i_sub_tables.end(), table_of_i);
if (element_loc != i_sub_tables.begin() + counter)
{
i_sub_tables.erase(i_sub_tables.begin() + counter);
}
else
{
std::vector<int> temp;
for (auto element : table_of_i)
{
temp.emplace_back(*element);
}
sub_tables.emplace_back(temp);
}
counter++;
}
return sub_tables;
}
void print_sub_tables(const std::vector<std::vector<int>>& sub_tables)
{
for (auto table : sub_tables)
{
std::cout << "[ ";
for (auto element : table)
{
std::cout << element << " ";
}
std::cout << "] ";
}
}
int main()
{
int n;
int d;
std::vector<int> table;
std::cin >> n;
std::cin >> d;
for (int i = 0; i < n; i++)
{
int temp;
std::cin >> temp;
table.emplace_back(temp);
}
auto sub_tables = get_sub_tables(table, d);
print_sub_tables(sub_tables);
std::cout << sub_tables.size();
return 0;
}