iterate for s range and then calculate total count of such integer if starting integer is found
for ( let i = s ; i <= Math . min ( n , s + 163 ) ; i ++ ) if ( ( i - digitSum ( i ) ) > s ) return ( n - i + 1 ) ;