Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		s := make([]string, n)
		for i := 0; i < n; i++ {
			s[i] = io.NextLine()
		}
		w := [5]int{5, 7, 5, 7, 7}
		ans := 0
	OUTER:
		for i := 0; i < n; i++ {
			cnt, wc := 0, 0
			for j := i; j < n; j++ {
				wc += len(s[j])
				if wc == w[cnt] {
					cnt++
					wc = 0
					if cnt == 5 {
						ans = i + 1
						break OUTER
					}
				} else if wc > w[cnt] {
					break
				}
			}
		}
		io.Println(ans)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: tanku=[5,7,5,7,7]
while True:
    n = int(input())
    
    if n == 0:
        break
    
    b = 0
    l = []
    wlen = 0
    for i in range(n):
        w = str(input())
        wlen = len(w)
        l.append(wlen)
        
    for i in range(len(l)):
        a = 0
        tan = 0
        for j in range(i,len(l)):
            a += l[j]
            
            if a > tanku[tan]:
                break
            
            elif a == tanku[tan]:
                if tan != 4:
                    tan += 1
                    a = 0
                elif tan == 4:
                    print(i+1)
                    b += 1
                    break
        if b != 0:
            break

Python: def main():
    while True:
        w_num = int(input())
        if w_num == 0: break

        w_list = []
        for i in range(w_num):
            w_list.append(input())

        for i in range(len(w_list)):
            #print(w_list)
            leng = 0
            for item in w_list:
                #print("leng" + str(leng))
                if leng < 5:
                    leng += len(item)
                    if leng > 5:
                        leng = 0
                        break
                elif leng < 12:
                    leng += len(item)
                    if leng > 12:
                        leng = 0
                        break
                elif leng < 17:
                    leng += len(item)
                    if leng > 17:
                        leng = 0
                        break
                elif leng < 24:
                    leng += len(item)
                    if leng > 24:
                        leng = 0
                        break
                else:
                    leng += len(item)
                    if leng > 31:
                        leng = 0
                        break
                    
                if leng == 31:
                    print(i + 1)
                    break
            if leng == 31: break
            del w_list[0]
main()

Python: def set(n):
    #n = int(input())
    #if n == 0:
     #   return False
    lis = []
    for i in range(n):
        lis.append(len(input()))

    return lis

def solve(lis , n):
    ans = 0
    while ans < 5:
        ans += lis[n]
        n +=1
    #    print(n)
    if not(ans == 5):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
   #     print(n)
    if not(ans == 7):
        return False


    ans = 0
    while ans < 5:
        ans += lis[n]
        n +=1
  #      print(n)
    if not(ans == 5):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
 #       print(n)
    if not(ans == 7):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
#        print(n)
    if not(ans == 7):
        return False
    return True

#main
while True:
    n = int(input())
    if not(n ==0):
        lis = set(n)
    for i in range(n):
        if solve(lis,i):
            print(i+1)
            break

        
    else:
        break

Python: 
while True:
  n = int(input())
  if n == 0:
    break
  haiku=[5,7,5,7,7]
  mojicnt=0
  iti=0
  s=[]
  for i in range(n):
    s.append(input())
  for i in range(n):
    for j in range(i,n):
      mojicnt += len(s[j])
      if mojicnt > haiku[iti]:
        continue
      elif mojicnt == haiku[iti]:
        iti+=1
        mojicnt=0
        if iti == 5:
          print(i+1)
          break
    if iti == 5:
      break
    else:
      mojicnt=0
      iti=0

Python: from itertools import count
q=(5,7,5,7,7)
while 1:
    l=[len(input()) for _ in range(int(input()))]
    for st in range(len(l)-4):
        c=0
        s=st
        for i in count(st):
            if c==5:break
            if sum(l[s:i])==q[c]:
                c+=1
                s=i
            elif sum(l[s:i])>q[c]:
                break
        if c==5:break 
    if len(l)>=5:
        print(st+1)    
    elif not l:
        break

Python: while True:
    N = int(input())
    if N == 0:
        break
    words = [len(input()) for _ in range(N)]

    for i in range(N):
        now = i
        tanku = [5, 7, 5, 7, 7][::-1]
        while tanku:
            while tanku[-1] > 0:
                tanku[-1] -= words[now]
                now += 1
            if tanku[-1] == 0:
                tanku.pop()
            else:
                break
        else:
            print(i + 1)
            break

Python: tanku = [5, 7, 5, 7, 7]
while True:
  n = int(input())
  if n==0:
    break
  w = [len(input()) for i in range(n)]
  ans = 0
  for i in range(n):
    sum = 0
    k = 0
    for j in range(i, n):
      sum += w[j]
      if sum == tanku[k]:
        sum = 0
        k += 1
        if k==5:
          ans = i+1
          break
      elif sum > tanku[k]:
        break
    if ans:
      break
  print(ans)

Python: while True:
    n = int(input())
    if n==0:
        break
    w = [len(input()) for i in range(n)]
    a = [5,7,5,7,7]
    ans = n+1
    for i in range(n):
        k,s = 0,0
        for j in range(i,n):
            s += w[j]
            if s==a[k]:
                s,k=0,k+1
            elif s>a[k]:
                break
            if k==5:
                ans = min(ans,i+1)
                break
    print(ans)