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<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>

using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
string s;
vector<int> array;
int hai[5]={5,7,5,7,7};
int now;
int Count;
int flag;
int owari;
int main()
{
	while(1)
	{
		owari=0;
		array.clear();
		cin>>n;
		if(n==0)break;
		rep(i,n)
		{
			cin>>s;
			array.push_back(s.size());
		}
		rep(i,n)
		{
			flag=0;
			now=i;
			Count=0;
			while(1)
			{
				if(now==n)break;
				Count+=array[now];
				if(Count>hai[flag])break;
				else if(Count==hai[flag])
				{
					if(flag!=4)
					{
						flag++;
						Count=0;
					}
					else
					{
						cout<<i+1<<endl;
						owari=1;
						break;
					}
				}
				now++;
			}
			if(owari==1)break;
		}
	}
	return 0;
}

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

string s[44];
int tanku[5] = {5, 7, 5, 7, 7};

void solve(int n) {
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            // use from i to j
            bool is_tanku = true;
            int now_idx = 0;
            int now_cnt = 0;
            for (int k = i; k <= j; k++) {
                now_cnt += s[k].size();
                if (now_cnt > tanku[now_idx]) {
                    is_tanku = false;
                    break;
                }
                else if (now_cnt == tanku[now_idx]) {
                    now_cnt = 0;
                    now_idx++;
                }
                if (now_idx == 5) break;
            }
            if (is_tanku && now_idx == 5) {
                cout << i + 1 << endl;
                return;
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(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>
char s[50],a[9]={6,8,6,8,8};
main(){for(int i,j,p,n,q;scanf("%d\n",&n),n;){for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<6;)for(p=i++,j=q=0;q>=0;)for(q=a[j++]-1;q>0;q-=s[p++]);
printf("%d\n",i);
}}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int a[5]={5,7,5,7,7};
int solve(){
	int n;
	cin >> n;
	if(!n)return 1;
	vector<int> len(n);
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		len[i]=(int)s.size();
	}
	for(int i=0;i<n;i++){
		vector<int> b(5,0);
		int id = 0;
		for(int j=i;j<n;j++){
			b[id]+=len[j];
			if(b[id]>a[id])break;
			if(b[id]==a[id])id++;
			if(id==5)break;
		}
		if(id==5){
			printf("%d\n",i+1);
			return 0;
		}
	}
}
int main(){
	while(!solve()){}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  while(1){
    int n;
    cin>>n;
    if(n == 0) break;
    string s;
    int nums[40];
    REP(i,0,n){
      cin>>s;
      nums[i] = (int)s.size();
    }
    REP(i,0,n){
      int p = 0;
      int ch[5] = {};
      bool flag = false;
      REP(j,i,n){
        ch[p] += nums[j];
        if((p==0 || p==2) && ch[p]==5){
          p++;
        }else if((p==1 || p==3 || p==4) && ch[p]==7){
          p++;
        }
        if(p==5){
          cout<<i+1<<endl;
          flag = true;
          break;
        }
      }
      if(flag) break;
    }

  }

  return 0;
}