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

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
    int n;
    cin >> n;

    while(n != 0) {
        vector<string> w(n);
        for (int i = 0; i < n; ++i) {
            cin >> w[i];
        }

        for (int j = 0; j < n; ++j) {
            int w_count = 0;
            int cur = j;

            while (w_count < 5 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 5) continue;

            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            w_count = 0;
            while (w_count < 5 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 5) continue;


            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            cout << j+1 << endl;
            break;
        }
        cin >> n;

    }
}

C++: // 2018/01/05 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		string w[40];
		int len[40];
		for(int i=0; i<n; i++){
			cin >> w[i];
			len[i] = w[i].size();
		}

		for(int i=0; i<n; i++){
			bool flg = false;
			int sta = 0;
			int sum = 0;

			for(int j=i; j<n; j++){
				sum += len[j];

				if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
					sta++;
				}

				if(sta==5){
					flg = true;
					break;
				}
				else if(sum>=31){
					break;
				}
			}

			if(flg){
				cout << i+1 << endl;
				break;
			}
		}
	}

	return 0;
}

C++: v[50],p,n,k,X;main(s){for(;n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;n;)for(n=0,p=++s,k=261096;k/=8;n+=X)for(X=k&7;X>0;X-=v[p++]);}}

C++: #include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

bool check_tanku(std::vector<std::string> v, int ind) {
	int piv = 0;
	int n = v.size();
	int l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}

	return true;
}

int main(void) {
	int n;
	int limit = 31;
	cin >> n;

	while ( n != 0 ) {
		std::vector<std::string> tan(n);
		std::vector<int> len(n,0);
		bool find = false;
		for (int i = 0; i < n; i++) {
			cin >> tan[i];
		}

		for (int i = 0; i < n; i++) {
			for (int j = i; j < n && len[i] < limit; j++) {
				len[i] += tan[j].length();
			}
		}

		int temp;
		for (int i = 0; i < n && !(find); i++) {
			if (len[i] == limit) {
				if (check_tanku(tan,i)) {
					cout << i+1 << endl;
					find = true;
				}
			}
		}

		cin >> n;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
        int N;
        while (cin>>N,N) {
                vector<int>D(N);
                for (int i = 0; i < N; i++) {
                        string S;
                        cin>>S;
                        D[i] = S.length();
                }
                for (int i = 0; i < N; i++) {
                        int j = i;
                        int sum = 0;
                        while (sum<5) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=5) {
                                continue;
                        }
                        while (sum<12) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=12) {
                                continue;
                        }
                        while (sum<17) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=17) {
                                continue;
                        }
                        while (sum<24) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=24) {
                                continue;
                        }
                        while (sum<31) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=31) {
                                continue;
                        }
                        cout<<i+1<<endl;
                        break;
                }
        }
}