#include <iostream>
#include <vector>
#include <algorithm>
int get_sub_tables(int* p_table, int size, int differece)
{
int n_sub_tables = 0;
for (auto left_i = p_table; left_i != p_table + size; ++left_i)
{
n_sub_tables++;
int min = *left_i;
int max = *left_i;
int n_digits = 1;
for (auto right_i = left_i + 1; right_i != p_table + size; )
{
if (*right_i > max)
max = *right_i;
else if (*right_i < min)
min = *right_i;
int d = max - min;
if (d <= differece)
{
if (right_i - left_i >= n_digits)
{
n_sub_tables++;
n_digits++;
right_i = left_i + 1;
min = *left_i;
max = *left_i;
continue;
}
else
++right_i;
}
else
break;
}
}
return n_sub_tables;
}
//int main()
//{
// int n;
// int difference;
// int table[100000];
// std::cin >> n;
// std::cin >> difference;
// for (int i = 0; i < n; i++)
// {
// std::cin >> table[i];
// }
// std::cout << get_sub_tables(table, n, difference);
// return 0;
//}