data Arrange = Twin | Single deriving (Show, Eq)

prime = 1000000007 :: Integer

abbr :: String -> [Arrange] -> [Arrange]
abbr [] xs = xs
abbr [_] xs = Single:xs
abbr (x:y:ys) xs
  | x == y = abbr ys (Twin:xs)
  | x /= y = abbr (y:ys) (Single:xs) 

(*->) :: Arrange -> Arrange -> Integer
pre *-> cur
  | pre == Twin && cur == Twin = 3
  | pre == Twin && cur == Single = 1
  | pre == Single && cur == Twin = 2
  | otherwise = 2
infixl 7 *->

solve :: [Arrange] -> Arrange -> Arrange -> Integer -> Integer
solve [] _ first ret = (if first == Twin then 6 else 3) * ret `mod` prime
solve [x] pre first ret = solve [] first Single $ pre *-> x *ret `mod` prime
solve (x:y:xs) _ first ret = solve (y:xs) first x $ x *-> y * ret `mod` prime

main = do
  getLine
  getLine
  str <- getLine
  let shrinked = reverse $ abbr str []
  case shrinked of
    [_] -> print 3
    _ -> print $ solve shrinked (head shrinked) Single 1
  
