
object Main extends App {
  import scala.io.StdIn._
  val mod = 1000000007L
  val n = readLine.trim.toInt
  val planets: Array[Planet] = readLine.trim.toCharArray.zip(readLine.trim.toCharArray).map{case (f, t) ⇒ new Planet(f, t)}
  val pattern = Array.tabulate(26){_ ⇒ 0L}.also(a ⇒ a(planets(0).in.toIndex) = 1)
  for (i ← 1 until planets.length - 1){
    pattern(planets(i).in.toIndex) = (pattern(planets(i).out.toIndex) + pattern(planets(i).in.toIndex)) % mod
  }
  println(pattern(planets(n - 1).out.toIndex))
  class Planet(val in: Char, val out: Char)
  implicit class CharToInt(val value: Char){
    def toIndex: Int = value - 'a'
  }
  implicit class ScopedFunc[T](val value: T){
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0386
