def find_tanku(words, st)
  phrase_length = [5, 7, 5, 7, 7]

  st.upto(40) do |index|
    head = phrase_length.shift - words[index].length

    case head
    when 0 then return st + 1 if phrase_length.empty?
    when -Float::INFINITY..-1 then return false
    else phrase_length.unshift(head)
    end
  end
end

loop do
  n = gets.to_i
  break if n == 0
  words = Array.new(n) { gets.chomp }

  n.times do |st|
    res = find_tanku(words, st)

    if res
      puts res
      break
    end
  end
end