Function to return the count of required strings
function countStr ( i , s ) { if ( i < 0 ) { if ( check ( s ) ) return 1 ; return 0 ; } let myNameChars = s . split ( " " ) ; myNameChars [ i ] = ' ' ; s = ( myNameChars ) . join ( " " ) ; let ans = countStr ( i - 1 , s ) ; let myChar = s . split ( " " ) ; myChar [ i ] = ' ' ; s = ( myChar ) . join ( " " ) ; ans += countStr ( i - 1 , s ) ; let myChar1 = s . split ( " " ) ; myChar1 [ i ] = ' ' ; s = ( myChar1 ) . join ( " " ) ; return ans ; }