while true
    n = gets.to_i
    break if n == 0
    arr, arr2 = [], [5, 7, 5, 7, 7]
    n.times{arr << gets.chomp.length}
    start, match = 0, false
    while true
        i, q = start, -1
        while true
            sum, q, i = arr[i], q + 1, i + 1
            while sum < arr2[q]
                sum += arr[i]
                i += 1
            end
            if sum == arr2[q]
                if q == 4
                    match = true
                    break
                end
            else
                break
            end
        end
        break if match
        start += 1
    end
    puts start + 1
end

