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<bits/stdc++.h>
int i,j,p,n,q,a[9]={5,7,5,7,7,-1},d[50];char s[50];main(){
for(;scanf("%d\n",&n),n;){for(i=0;i<n;)d[++i]=strlen(gets(s));
for(i=1;;i++){for(p=i,j=0,q=0;q>=0;){q=a[j];for(j++;q>0;p++)q-=d[p];}if(j>5)break;}
printf("%d\n",i);
}}

C++: // 2016-12-12
#include <iostream>
#include <string>
using namespace std;

int main() {
	int t[5] = {5, 7, 5, 7, 7};
	int n, a[40];
	string s;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> s;
			a[i] = s.length();
		}
		bool b = false;
		for (int i = 0; i < n; i++) {
			for (int j = i, k = 0, m = 0; j < n; j++) {
				m += a[j];
				if (m == t[k]) {
					k++;
					m = 0;
					if (k == 5) {
						b = true;
						break;
					}
				} else if (m > t[k]) {
					break;
				}
			}
			if (b) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

int d[5] = {5,7,5,7,7};

int main(){
	int n;
	while(cin >> n,n){
		vector<int> v;
		for(int i=0;i<n;i++){
			string s;
			cin >> s;
			v.emplace_back(s.size());
			//cout << s.size() << endl;
		}
		int sum=0;
		int idx=0;
		int start=0;
		for(int unsigned i=0;i<v.size();i++){
			sum+=v[i];
			//cout << v[i] << " " << sum << " " << d[idx] << " " << i << " " << " " << idx << " " << start << endl;
			if(sum == d[idx]){
				idx++;
				sum=0;
			} else if(sum > d[idx]){
				idx=0;
				i = start;
				start=i+1;
				sum=0;
			}
			if(idx >= 5){
				cout << start+1 << endl;
				break;
			}
		}
		//cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
while(1){
ll n;
cin >>n;
if(n==0){
break;
}
string name[n];
REP(i,n){
cin>>name[i];
}
ll num[n];
REP(i,n){
num[i]=name[i].length();
}

REP(i,n){
ll len=0;
ll now=i;
while(len<5){
len+=num[now];
now++;
}

if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<5){
len+=num[now];
now++;
}
if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
cout<<i+1<<endl;
break;
}
}
}

}
}

}





}


return 0;
}

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

int main()
{
  int n;
  int len[101];
  string s;
  int num[5]={5,7,5,7,7};

  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>s;
      len[i]=s.length();
    }

    int ans=0;
    for(int i=0;i<n;i++){
      int sum=0,c=0;
      for(int j=i;j<n;j++){
	sum+=len[j];
	if(sum==num[c]){
	  sum=0;
	  c++;
	}
	else if(num[c]<sum)break;
	if(c==5)break;
      }
      if(c==5){
	ans=i;
	break;
      }
    }
    cout<<ans+1<<endl;
  }

  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin>>n,n){
        vector<int> v(n);
        REP(i,n){
            string s; cin>>s;
            v[i]=s.size();
        }

        REP(i,n){
            int pos=i;
            int j,A[]={5,7,5,7,7};
            for(j=0;j<5;j++){
                int cnt=0;
                while(pos<n && cnt<A[j]) cnt+=v[pos++];
                if(cnt!=A[j]) break;
            }
            if(j==5){
                cout<<i+1<<endl; break;
            }
        }
    }
}

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


using namespace std;


bool solve()
{
	int n; cin >> n;
	vector<string> w(n);

	if (n == 0)return false;

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

	for (int i = 0; i < w.size(); ++i)
	{
		list<int> mojisu{ 5,7,5,7,7 };
		for (int j = i; j < w.size(); ++j)
		{
			mojisu.front() -= (int)w[j].size();

			if (mojisu.front() == 0)
			{
				mojisu.pop_front();
				if (mojisu.empty())
				{
					cout << i+1 << endl;
					return true;
				}
			}
			else if (mojisu.front() < 0)
			{
				break;
			}

		}
	}
}


int main()
{
	while (solve())
	{
		
	}
}

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

int main() {

	while (1) {
		int n;
		cin >> n;
		if (n == 0)
			break;

		string word;
		int *length = new int[n];
		int key[5] = { 5,7,5,7,7 };
		for (int i = 0; i < n; i++) {
			cin >> word;
			length[i] = word.size();
		}

		int count = 0;
		int section = 0;
		int index = 0;
		int output = 0;
		int start = 0;
		bool found = false;
		while (index != n) {
			index = output;
			output++;

			while (count <= 5) {
				if (key[count] > section) {
					section += length[index++];
				}
				else if (key[count] == section) {
					section = 0;
					count++;
				}
				else {
					break;
				}

				if (count == 5) {
					cout << output << endl;
					found = true;
				}
			}
			count = 0;
			section = 0;
			if (found)
				break;
		}
	}
	return 0;
}

C++: s[50],j,p,q;main(i){for(;p=atoi(gets(s));printf("%d\n",i)){for(i=0;i<p;s[i++]=strlen(gets(s+i)));for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=j++>5?0:j-2&&j-4?8:6;q>1;q-=s[p++]);}}