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

Python: ans_list = []

def make_tanka(num, w_list, i):
    #print(num, w_list, i)
    cnt = 0
    while cnt < num:
        cnt += len(w_list[i])
        i += 1
    return [cnt, i]

while True:
    n = int(input())
    if n == 0:
        break
    w_list = []
    for i in range(n):
        w_list.append(input())

    f1 = 0
    s1 = 0
    f2 = 0
    s2 = 0
    s3 = 0
    i = 0
    ans = -1
    while True:
        #print(i)
        j = i
        f1, j = make_tanka(5, w_list, j)
        if f1 == 5:
            s1, j = make_tanka(7, w_list, j)
            if s1 == 7:
                f2, j = make_tanka(5, w_list, j)
                if f2 == 5:
                    s2, j = make_tanka(7, w_list, j)
                    if s2 == 7:
                        s3, j = make_tanka(7, w_list, j)
                        if s3 == 7:
                            ans = i
                            break
                    if ans != -1:
                        break
                if ans != -1:
                    break
            if ans != -1:
                break
        if ans != -1:
            break
        i += 1
    ans_list.append(ans + 1)

for i in ans_list:
    print(i)