import qualified Data.ByteString.Char8 as C

main = C.interact $ put . sol . get

get = tail . C.words

put = C.pack . show

sol [s1,s2] = g 1 . f [] $ C.zipWith (\a b -> if a==b then 1 else 2) s1 s2

f s []        = s
f s [a]       = a:s
f s (2:2:as)  = f (2:s) as
f s (2:1:as)  = error "whoa!"
f s (1:a:as)  = f (1:s) (a:as)

g t []        = t
g t [1]       = t .*. 3
g t [2]       = t .*. 6
g t [2,2]     = t .*. 18
g t [a,a']    = t .*. 6
g t (1:2:as)  = g t         (2:as)
g t (2:2:as)  = g (t .*. 3) (2:as)
g t (a:a':as) = g (t .*. 2) (a':as)

(.*.) = ((`mod` p) .) . (*)

p = 10^9+7 :: Int