object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val charCounts =
    Seq.fill(sc.nextInt())(sc.next()).map(_.toCharArray.toSeq.groupBy(identity).map { case (key, value) => key.hashCode() -> value.size })
  val groupCounts = charCounts.groupBy(identity).mapValues(_.size).values
  println(groupCounts.foldLeft(0L)((acc, i) => acc + (1 until i).sum))
}