object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    val words = List.tabulate(n){_ ⇒ readLine.trim}
    println(findTanka(words))
    solve
  }
  def findTanka(words: List[String]): Int= {
    val tankaNumber: List[Int] = List(5, 7, 5, 7, 7)
    def canMakeStraight(words: List[String], rest: List[Int] = tankaNumber): Boolean = {
      (words, rest) match {
        case (_, Nil) ⇒ true
        case (h::t, f::l) if h.length < f ⇒ canMakeStraight(t, f - h.length::l)
        case (h::t, f::l) if h.length == f ⇒ canMakeStraight(t, l)
        case _ ⇒ false
      }
    }
    def sub(words: List[String], index: Int = 1): Int = {
      if (canMakeStraight(words, tankaNumber)) index
      else sub(words.tail, index + 1)
    }
    sub(words)
  }

  @inline
  def lowerBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) < 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  @inline
  def upperBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) <= 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
