
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val mod = 1000000007L
  println(
    calPattern(readLine.trim, readLine.trim)
  )
  def calPattern(stone: String, voodoo: String): Long = {
    val result = Array.tabulate(voodoo.length + 1){ _ ⇒ 0L}.also{ arr ⇒ arr(0) = 1L}
    for (c ← stone){
      for (i ← voodoo.indices.reverse){
        if (c == voodoo(i)){
          result(i + 1) += result(i)
          result(i + 1) %= mod
        }
      }
    }
    result.last
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*


 */
