import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Char (ord)
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = solve <$> readLn <*> B.getLine <*> B.getLine >>= print

solve :: Int -> ByteString -> ByteString -> Int
solve n bs bt = runST $ do
  dp <- VM.replicate 26 0 :: ST s (STVector s Int)
  let Just (s0, bs0) = B.uncons bs
  let Just (_, bt0) = B.uncons bt
  VM.write dp (idx s0) 1
  (_, btn) <- foldM (\(bs, bt) _ -> do
                        let Just (s, bs') = B.uncons bs
                        let Just (t, bt') = B.uncons bt
                        x <- VM.read dp (idx s)
                        y <- VM.read dp (idx t)
                        VM.write dp (idx s) ((x + y) `mod` 1000000007)
                        return (bs', bt')
                    ) (bs0, bt0) [1 .. n-2]
  let Just (tn, _) = B.uncons btn
  VM.read dp (idx tn)

idx :: Char -> Int
idx c = ord c - ord 'a'

