Go: // Short Phrase(短句)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1601&lang=jp
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		n := nextInt(sc)
		if n == 0 {
			break
		}

		var words []string
		for i := 0; i < n; i++ {
			words = append(words, nextString(sc))
		}

		res := 0
		for i := 0; i < n; i++ {
			tmpWords := words[i:]
			ok := checkRule(tmpWords, 0)
			if ok {
				res = i + 1
				break
			}
		}

		fmt.Println(res)
	}
}

var rule = [5]int{5, 7, 5, 7, 7}

func checkRule(words []string, depth int) bool {
	var shortPhrase = ""
	var i = depth

	if depth == 5 {
		return true
	}

	for len(words) > 0 {
		shortPhrase += words[0]
		words = words[1:]

		if rule[i] == len(shortPhrase) {
			return checkRule(words, i+1) // 短句のルールを満たしたので次の文節へ
		} else if rule[i] < len(shortPhrase) {
			return false // 文節の語数オーバー
		}
	}

	return false // 文節を満たす単語が足りない
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

Python: checklis = [5,7,5,7,7]
def check(S):
    b = 0
    index = 0
    for s in S:
        b += len(s)
        if checklis[index] == b:
            index += 1
            b = 0
            if index == 5:
                return True
        elif checklis[index] > b:
            continue
        else:
            return False
    return False

def main(n):
    s = [input() for i in range(n)]
    for i in range(n):
        if check(s[i:]):
            print(i + 1)
            return

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

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: from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    n = int(input())
    if n == 0:
        break
    else:
        ww = [len(input()) for i in range(n)]

        L = [5,7,5,7,7]
        for i in range(n):
            k = i
            tmp = 0
            S = 0
            flag = False
            while True:
                w = ww[k]
                if L[tmp] - S > w:
                    S += w
                elif L[tmp] - S == w:
                    tmp += 1
                    S = 0
                else:
                    break

                if tmp == 5:
                    flag = True
                    break

                k += 1

            if flag:
                print(i+1)
                break

Python: # coding: utf-8
while 1:
    data=[]
    for i in range(int(input())):
        data.append(len(input()))
    if len(data)==0:
        break
    for i in range(len(data)):
        j=i
        tmp=0
        while tmp<5:
            tmp+=data[j]
            j+=1
        if tmp!=5:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        tmp=0
        while tmp<5:
            tmp+=data[j]
            j+=1
        if tmp!=5:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        print(i+1)
        break

Python: def solve():
    n = int(input())
    if n == 0: return False

    ok = [5, 7, 5, 7, 7]

    inputs = [input() for x in range(n)]

    for i in range(n):
        target = 0
        cnt = i
        for v in ok:
            while target < v:
                s = inputs[cnt]
                target += len(s)
                cnt += 1
            if target != v:
                break
            else:
                target = 0
        else:
            print(i + 1)
            return True
    return True
while solve(): pass

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