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: 
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)

Python: flag=False

def dbg(a,b=None):
  print(a,b) if flag else None
  
def hante(arr,num):
  sum=0
  for i in range(len(arr)):
    sum+=arr[i]
    if sum==num:
      dbg((True,i),arr)
      return (True,i+1)
    if sum>num:
      dbg((False,None),arr)
      return (False,None)
  dbg((False,None),arr)
  return (False,None)


while True:
  n=int(input())
  if n==0:
    break;
  mojisuu=0
  w=["" for i in range(n)]
  for i in range(n):
    x=len(input())
    w[i]=x
    mojisuu+=x
  start=0
  while start<mojisuu:
    
    h1=hante(w[start:],5)
    if not h1[0]:
      start+=1
      continue
    h2=hante(w[start+h1[1]:],7)
    if not h2[0]:
      start+=1
      continue
    h3=hante(w[start+h1[1]+h2[1]:],5)
    if not h3[0]:
      start+=1
      continue
    h4=hante(w[start+h1[1]+h2[1]+h3[1]:],7)
    if not h4[0]:
      start+=1
      continue
    h5=hante(w[start+h1[1]+h2[1]+h3[1]+h4[1]:],7)
    if not h5[0]:
      start+=1
      continue
    break
  print(start+1)

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = [len(S()) for _ in range(n)]

        def f(i):
            t = [5,7,5,7,7]
            ti = 0
            for c in a[i:]:
                if c > t[ti]:
                    return False
                if t[ti] == c:
                    ti += 1
                    if ti == 5:
                        return True
                else:
                    t[ti] -= c
            return False

        r = 0
        for i in range(n):
            if f(i):
                r = i+1
                break

        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

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

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

Python: tanka = (5, 7, 5, 7, 7, 0)
words = list()
n = int()

def rec(step, itr, word):
    if step == 5:
        return True

    if word == 0:
        return rec(step + 1, itr, tanka[step + 1])
    elif word < 0:
        return False
    
    return rec(step, itr + 1, word - words[itr])

while True:
    n = int(input())
    if n == 0:
        break

    words = [len(str(input())) for i in range(n)]
    for i in range(n):
        if rec(0, i, tanka[0]):
            print(i + 1)
            break