object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val n = sc.nextInt()
    val sList = List.fill(n)(sc.next())
    val sGrouped = sList.groupBy(s => s).mapValues(_.size).toList

    val m = sc.nextInt()
    val tList = List.fill(m)(sc.next())
    val tGrouped = tList.groupBy(s => s).mapValues(_.size).toList

    val foo = sGrouped.filter(p1 => tGrouped.exists(p2 => p1._1 == p2._1 && p1._2 > p2._2))

    if (foo.isEmpty){
      println(foo(0)._2)
    } else {
      println(0)
    }
  }
}