Function to find the required count
function findCount ( N , K , arr ) { let count = 0 ; for ( let i = 0 ; i < K ; i ++ ) { count = checkLastDigit ( arr [ i ] ) == 1 ? count + 1 : count ; } document . write ( count + " " ) ; }