import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  def find(s: String, t: String): Boolean = {
    for(i <- 0 until t.size) {
      val u = t.drop(i) ++ t.take(i)
      if(u.startsWith(s)) {
        return true
      }
    }
    return false
  }
  def main(args: Array[String]) {
    val s = sc.next
    val n = sc.nextInt
    var ans = 0
    for(i <- 1 to n) {
      val t = sc.next
      if(find(s, t)) {
        ans += 1
      }
    }
    println(ans)
  }
}