import scala.annotation.tailrec

object Main extends App {
  import scala.collection.mutable
  import scala.io.StdIn._

  val n = readInt
  val words = Array.tabulate(n){_ ⇒ readLine.trim}
  println(minLength(words))

  def minLength(words: Array[String]): Int = {
    @tailrec
    def sub(current: Int = 0, prevLength: Int = 0, minWithChar: IndexedSeq[Int] = mutable.IndexedSeq.tabulate(26){_ ⇒ -1}): Int = {
      if (current == words.length) prevLength
      else {
        if (minWithChar(words(current).head - 'a') != -1) {
          val minLen: Int = math.min(prevLength + 1, minWithChar(words(current).head - 'a'))
          sub(current + 1, minLen, minWithChar.updated(words(current).head - 'a', minLen))
        }else {
          sub(current + 1, prevLength + 1, minWithChar.updated(words(current).head - 'a', prevLength + 1))
        }
      }
    }
    sub()
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}
