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<vector>
#include<iostream>
#include<string>
using namespace std;
int a0 = 5;
int a1 = 7;
int a2 = 5;
int a3 = 7;
int a4 = 7;
int main() {
	int n;
	while (cin >> n, n != 0) {
		vector<int>v(n);
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			int x = str.size();
			v[i] = x;
		}
		for (int i = 0; i < n; i++) {
			int k = i;
			int ans = i;
			int a = a0;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				

			}
			a = a1;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a2;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a3;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a4;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					cout << ans + 1 << endl;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
		OUT:
			;
		}

	}
	return 0;
}


// 5 12 17 24 31

C++: #include<stdio.h>
#include<string.h>

int main(void){
	int n,n_l[40],count=0,cap=0;
	char w[10];
	scanf("%d",&n);

	int i;
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%s",w);
			n_l[i]=strlen(w);
		}
		for(i=0;;i++){
			count=0;
			cap=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			count=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			break;
		}
		printf("%d\n",i+1);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> w;
	for (int i = 0;i < n;++i) {
		string tmp;
		cin >> tmp;
		w.push_back(tmp);
	}

	int flag = 0;
	int len = 0;
	int output=100000000;
	for (int i = 0;i < n;++i) {
		flag = 0;
		len = 0;
		for (int j = i; j< n;++j) {
			len += w[j].size();
			if (flag == 0 || flag == 2) {
				if (len == 5) {
					len = 0;
					flag++;
				}
				else if (len > 5) {
					break;
				}
			}
			else {
				if (len == 7) {
					len = 0;
					flag++;
				}
				else if (len > 7) {
					break;
				}
			}
		}

		if (flag >= 5) {
			output = i+1;
			break;
		}
	}

	cout << output << endl;

}

C++: #include <bits/stdc++.h>
using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N;
    vector<int> num = {5, 7, 5, 7, 7};

    while (cin >> N, N) {
        vector<string> S(N);
        rep(i, N) cin >> S[i];

        rep(i, N) {
            int tmp_len = 0;
            int num_idx = 0;
            bool ok = false;
            
            for (int j=i; j<N; j++) {
                if (tmp_len < num[num_idx]) {
                    tmp_len += S[j].size();
                }

                if (tmp_len == num[num_idx]) {
                    num_idx++;
                    tmp_len = 0;
                } else if (tmp_len > num[num_idx]) {
                    break;
                }

                if (num_idx == 5) {
                    ok = true;
                    break;
                }
            }
            if (ok) {
                cout << i+1 << endl;
                break;
            }
        }
    }
}