Could some one please tell me why i am getting wrong answer for this problem https://www.spoj.pl/problems/SETNJA/. Technically this algorithm should time limit exceed as posts regarding this problem suggest .
Thank you

import qualified Data.ByteString.Char8 as BS
import Data.List as L
solve :: BS.ByteString -> Integer
solve xs = solverHelp xs 1  where 
   solverHelp ys p 
	| BS.null ys == True = p
	| otherwise =  case BS.head ys of 
		'L' -> solverHelp  ( BS.tail ys )  2*p 
		'R' -> solverHelp  ( BS.tail ys ) ( 2*p + 1 ) 
		'P' -> solverHelp  ( BS.tail ys )  p
		'*' -> solverHelp  ( BS.tail ys )  p + solverHelp  ( BS.tail ys )  ( 2*p ) + solverHelp  ( BS.tail ys )  ( 2*p + 1 )
main = BS.interact $ BS.unlines . map ( BS.pack . show . solve ) . BS.lines