#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include<vector>
int main() {
// your code goes here
int arr[]={1,2,3};
int n=3;
int k=2;
int count=0,diff=0,left=0,right=2;
sort(arr,arr+n);
while(left<n && right>=0)
{
diff=arr[right]-arr[left];
if(diff<=k)
{
diff=arr[right]-arr[left];
count++;
left++;
}
if(diff>k)
{
right--;
}
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8dmVjdG9yPgoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglpbnQgYXJyW109ezEsMiwzfTsKCWludCBuPTM7CglpbnQgaz0yOwoJaW50IGNvdW50PTAsZGlmZj0wLGxlZnQ9MCxyaWdodD0yOwoJc29ydChhcnIsYXJyK24pOwogICAgCiAgICAgd2hpbGUobGVmdDxuICYmIHJpZ2h0Pj0wKQogICAgICB7CiAgICAgIAlkaWZmPWFycltyaWdodF0tYXJyW2xlZnRdOwogICAgICAJaWYoZGlmZjw9aykKICAgICAgCSB7CiAgICAgIAkgCWRpZmY9YXJyW3JpZ2h0XS1hcnJbbGVmdF07CiAgICAgIAkgCWNvdW50Kys7CiAgICAgIAkgCWxlZnQrKzsKICAgICAgCSAJCiAgICAgIAkgfQogICAgICAJIGlmKGRpZmY+aykKICAgICAgCSAgewogICAgICAJICAJcmlnaHQtLTsKICAgICAgCSAgfQogICAgICB9CiAgICAgIGNvdXQ8PGNvdW50OwoJIAoJCgkgCglyZXR1cm4gMDsKfQ==