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: while True:
    n = int(input())
    if n == 0:
        break
    else:
        phlist=[]
        phflag=0
        for i in range(n):
            phlist.append(input())

        for i in range(len(phlist)-4):
            cur=0
            state=0
            for j in range(i, len(phlist)):
                s = phlist[j]
                cur+=len(s)
                if state==0 and cur<5:
                    continue
                elif state==0 and cur==5:
                    cur=0
                    state=1
                elif state==1 and cur<7:
                    continue
                elif state==1 and cur==7:
                    cur=0
                    state=2
                elif state==2 and cur<5:
                    continue
                elif state==2 and cur==5:
                    cur=0
                    state=3
                elif state==3 and cur<7:
                    continue
                elif state==3 and cur==7:
                    cur=0
                    state=4
                elif state==4 and cur<7:
                    continue
                elif state==4 and cur==7:
                    print(i+1)
                    phflag=1
                    break

            if phflag:
                break

Python: def main():
    while True:
        n = int(input().strip())

        if n == 0:
            break

        phrases = []
        for _ in range(n):
            word = input().strip()
            phrases.append(word)

        PHRASE_LEN = [5,7,5,7,7]
        found_flag = False

        for i in range(n):
            acc_len = 0
            phrase_idx = 0
            for j in range(i, n):
                acc_len += len(phrases[j])

                if acc_len == PHRASE_LEN[phrase_idx]:
                    if phrase_idx == (len(PHRASE_LEN)-1):
                        found_flag = True
                        break

                    acc_len = 0
                    phrase_idx += 1
                elif acc_len > PHRASE_LEN[phrase_idx]:
                    break

            if found_flag:
                print(i+1)
                break

if __name__ == "__main__":
    main()

Python: def es(k,le):
    i=k
    x=0
    while le>x:
        x+=len(l[i])
        i+=1
    if le==x:return i
    else: return 0



while True:
    n=int(input())
    if n==0:break
    l=[input() for _ in range(n)]
    ans=1
    for i in range(n):
        k=i
        k=es(k,5)
        if k==0:continue
        k=es(k,7)
        if k==0:continue
        k=es(k,5)
        if k==0:continue
        k=es(k,7)
        if k==0:continue
        k=es(k,7)
        if k==0:continue
        print(ans+i)
        break

Python: while True:
    n = int(input())
    if n == 0:
        break
    count = [0] * n
    for i in range(n):
        count[i] = len(input())
    for i in range(n-4):
        ind = i
        fin = True
        for tmp in [5, 7, 5, 7, 7]:
            while tmp > 0 and ind < n:
                tmp -= count[ind]
                ind += 1
            if tmp != 0:
                fin = False
                break
        if fin:
            print(i+1)
            break

Python: while True:
    n = int(input())
    if n == 0:
        break
    else:
        words = []
        for i in range(n):
            w = input()
            words.append(w)
        check = [5, 7, 5, 7, 7]
        flag = 0
        count = 1
        while True:
            w_len = 0
            for i in range(count-1, n):
                w_len += len(words[i])
                if w_len == check[flag]:
                    flag += 1
                    w_len = 0
                elif w_len > check[flag]:
                    flag = 0
                    break
                if flag == 5:
                    print(count)
                    break
            if flag == 5:
                break
            else:
                count += 1

Python: p = [5, 7, 5, 7, 7]
while True:
    n = int(input())
    if n == 0:
        break
    word = [input() for _ in range(n)]
    flag = False
    for i in range(len(word)):
        ip = 0
        phrase = ["" for _ in range(len(p))]
        if flag:
            break
        for j in range(i, len(word)):
            if len(phrase[ip]+word[j]) == p[ip]:
                phrase[ip] += word[j]
                ip += 1
            else:
                phrase[ip] += word[j]
                if len(phrase[ip]) > p[ip]:
                    break
                if len(phrase[ip]) == p[ip]:
                    ip += 1
            if len(phrase[-1]) == 7:
                print(i+1)
                flag = True
                break

Python: "短句"
# 各単語を始まりとして57577が作れるかどうか
while True:
    n = int(input())
    if n == 0:
        break
    words = [str(input()) for _ in range(n)]

    tanku = [5, 7, 5, 7, 7]
    target = 0
    ans = 0
    for i in range(n):
        now_len = 0
        # print("i : ", i)
        for j in range(i, n):
            now_len += len(words[j])
            # print(words[j], now_len)

            if now_len == tanku[target]:
                now_len = 0
                target += 1
            elif now_len < tanku[target]:
                pass
            elif now_len > tanku[target]:
                target = 0
                break

            if target == 5:
                break
        if target == 5:
            ans = i
            break
    print(ans+1)