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: a = [5,7,5,7,7]
 
while True:
    n = int(input())
    if n == 0: break
    w = list(map(lambda x: len(input()) , range(n)))
    ans = 0
    for i in range(n):
        aa, g = 0, 0
        for j in range(i, n):
            g += w[j]
            if g == a[aa]:
                g =  0
                aa += 1
                if aa == 5:
                    ans = i+1
                    break
            elif g > a[aa]:
                break
        if ans:
            break
    print(ans)

Python: while True:
    n = int(input())
    if n == 0:
        break
    w = []
    go = 0
    flag = True
    x = 0
    count = 0
    for i in range(n):
        w.append(input())
    else:
        while count < 5:
            for i in range(x,n):
                go += len(w[i])
                if flag == True:
                    if go == 5:
                        flag = False
                        count += 1
                        go = 0
                    if go > 5:
                        x += 1
                        go = 0
                        count = 0
                        break
                if flag == False:
                    if go == 7 and count == 3:
                        flag = False
                        count += 1
                        go = 0
                    if go == 7:
                        flag = True
                        count += 1
                        go = 0
                    if go > 7:
                        x += 1
                        go = 0
                        count = 0
                        flag = True
                        break
                if count == 5:
                    break
    print(x + 1)

Python: target = [5,7,5,7,7]
while True:
    N = int(input())
    if N == 0: break
    src = [len(input()) for i in range(N)]
    ans = -1
    for i in range(N):
        j = i
        _t = target[::-1]
        while True:
            if src[j] > _t[-1]: break
            if src[j] == _t[-1]:
                _t.pop()
                if len(_t) == 0:
                    ans = i+1
                    break
            else:
                _t[-1] -= src[j]
            j += 1
        if ans >= 0:
            print(ans)
            break

Python: fs = [5, 7, 5, 7, 7]
while True:
    flag = 0
    n = int(input())
    if n == 0:
        quit()
    w = []
    for i in range(n):
        w.append(len(input()))
    for i in range(len(w)):
        k, temp = 0, 0
        for j in range(i, len(w)):
            temp += w[j]
            if temp > fs[k]:
                break
            elif temp == fs[k]:
                if k == 4:
                    print(i+1)
                    flag = 1
                    break
                else:
                    k += 1
                    temp = 0
        if flag == 1:
            break

Python: s = [5,7,5,7,7]


def solve(n):
    num = [len(input()) for _ in range(n)]

    for i in range(n):
         c = 0
         k = 0
         for j in range(i,n):
             c+= num[j]
             if c==s[k]:
                 k+=1
                 c = 0
                 if k == 5:
                     print(i+1)
                     return
             if c > s[k]:
                 break


while 1:
    n = int(input())
    if n == 0:
        break
    solve(n)

Python: while True:
    n = int(input())#文字列の量
    if n == 0:
        break
    w = list()#文字用
    for i in range(0, n):#入力
        w.append(input())

    for j in range(1, n+1):#始めの文字の場所
        ck = 0
        co = 0
        p = 0
        t = ""
        for k in range(j-1,50):#５７５７７チェック用
            #print(k)
            if co == 0 or co == 2:#５の場所
                if ck < 5:#五以下
                    #print("<")
                    ck = ck + len(w[k+p])#文字増やす
                elif ck == 5:#ピッタリになったら
                    #print("==")
                    co = co + 1#次に移る
                    ck = 0
                    p = p-1
                else:#オーバーしたら
                    #print(">")
                    break
            else:
                if ck < 7:
                    #print("<7")
                    ck = ck+len(w[k+p])
                    #print("      " ,ck)
                elif ck == 7:
                    #print("==7")
                    co = co+1
                    ck = 0
                    p = p-1
                    if co == 5:
                        t = "fin"
                        break
                else:
                    #print(">7")
                    break

        print(j)
        if t == "fin":
            break
    #print("over")

Python: ans_list = []

def judge(array):
    res = 0
    cnt = 0
    st = [5,7,5,7,7,400]
    for a in array:
        res += len(a)
        if res > st[cnt]:
            return False
        if res == st[cnt]:
            cnt += 1
            res = 0
    if cnt == 5:
        return True

while True:
    n = int(input())
    if n == 0:
        break
    W = [input() for _ in range(n)]
    for i in range(n):
        part = W[i:]
        if judge(part):
            ans = i + 1
            break
    ans_list.append(ans)

for ans in ans_list:
    print(ans)