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: r = [5, 7, 5, 7, 7]
while True:
    n = int(input())
    if n == 0:
        break
    w = []
    for _ in range(n):
        w.append(len(input()))
    for j in range(n):
        i = j
        for k in r:
            s = 0
            while s < k:
                s = s + w[i]
                i = i + 1
            if s != k:
                break
        else:
            print(j+1)
            break

Python: # AOJ 1601: Short Phrase
# Python3 2018.7.13 bal4u

a = [5,7,5,7,7]

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

Python: # coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

while True:
    N = int(input())
    
    if N == 0:
        break
    
    S = []
    ans = None
    flag = False

    for i in range(N):
        S.append(len(input()))

    #print(S)

    for i in range(N):
        for j in range(i, N):
            A = S[i:j+1] 
            C = [5, 12, 17, 24, 31]
            #print(sum(A))
            if sum(A) == 31:
                for k in A:
                    C = [x-k if x != 0 else x for x in C]
            if sum(C) == 0:
                ans = i
                flag = True
                break
        if flag:
            break

    print(ans+1)

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

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

Python: class CheckError(Exception):
    pass

def check(wclist, count):
    c = 0
    while True:
        c += wclist.pop(0)
        if c == count:
            return wclist
        elif c > count:
            raise CheckError

def tanku_check(wclist):
    for i in range(len(wclist)):
        try:
            wcl = wclist[:][i:]
            wcl = check(wcl, 5)
            wcl = check(wcl, 7)
            wcl = check(wcl, 5)
            wcl = check(wcl, 7)
            wcl = check(wcl, 7)
            return i+1
        except CheckError:
            pass

def main():
    while True:
        n = int(input().strip())
        if n == 0:
            break
        wclist = [len(input().strip()) for _ in range(n)]
        print(tanku_check(wclist))

if __name__ == '__main__':
    main()