Check for all starting characters
for ( var c1 = ' ' . charCodeAt ( 0 ) ; c1 <= ' ' . charCodeAt ( 0 ) ; c1 ++ ) ma = Math . max ( ma , solve ( s , String . fromCharCode ( c1 ) ) * 2 ) ; document . write ( ma ) ;