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: def check(word):
    l = 0
    step = 0
    for w in word:
        l += len(w)
        if step == 0 or step == 2:
            if l == 5:
                step += 1
                l = 0
            elif l > 5:
                return False
        elif step == 1 or step == 3:
            if l == 7:
                step += 1
                l = 0
            elif l > 7:
                return False
        elif step == 4:
            if l == 7:
                return True
    return False


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

    word = []
    for _ in range(n):
        word.append(input())

    cnt = 0
    while word != []:
        cnt += 1
        if check(word):
            break
        word.pop(0)

    print(cnt)

Python: import sys


from inspect import currentframe


def pri(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    # print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(n, w_count):
    pri("solve")
    right_count = [5, 7, 5, 7, 7]

    for i in range(n):
        locate = 0
        way_count = 0
        pri(i)

        for w_i in w_count[i:]:
            if right_count[locate] == w_i + way_count:
                locate += 1
                way_count = 0
            elif right_count[locate] > w_i + way_count:
                way_count += w_i
            else:
                break

            if locate == 5:
                print(i + 1)
                return


    return


if __name__ == '__main__':
    while True:
        n_input = int(input())
        if n_input == 0:
            break
        w_count_imput = [len(input()) for i in range(n_input)]

        solve(n_input, w_count_imput)

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