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>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int d[5]={5,7,5,7,7};
int num[40];
int n;
bool rec(int s){
    int sum=0;
    int t[5];
    REP(i,5)t[i]=d[i];
    int ss=0;
    for(int i=s;i<n;i++){
        if(t[ss]>0)t[ss]-=num[i];
        else{
            ss++;
            t[ss]-=num[i];
        }
    }
    REP(i,5)if(t[i]!=0)return false;
    return true;
}
int main(){
    while(1){
        cin>>n;
        if(n==0)break;
        REP(i,n){
            string s;cin>>s;
            num[i]=s.size();
        }
        REP(i,n){
            if(rec(i)){
                cout<<i+1<<endl;
                break;
            }
        }
    }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
    int n;
    string s;
    int len[5] = {5,7,5,7,7};
    int count;
    int now;
    int ans;
    while(1){
        cin >> n;
        if(n==0) return 0;
        vector<int> w(n);
        for(int i=0;i<n;i++){
            cin >> s;
            w[i]=s.length();
        }
        ans=-1;
        for(int i=0;i<n;i++){
            count = 0;
            now = 0;
            for(int j=i;j<n;j++){
                count+=w[j];
                if(count==len[now]){
                    now++;
                    count=0;
                    if(now==5){
                        ans=i;
                    }
                }else if(count>len[now]){
                    break;
                }
            }
            if(ans != -1){
                break;
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int i,j,k;
    string buf;
    int d[50]={};
    for(i=0;i<n;i++){
      cin >> buf;
      d[i]=buf.size();
    }
    for(i=0;i<n;i++){
      int c=0;
      j=i;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f; i<n; ++i)
#define rep(i,n) reps(i,0,n)

void solve(int n)
{
    vector<int> v(n);
    
    rep(i, n){
        string s;
        cin >> s;
        v[i] = s.size();
    }
    
    const int len[] = {5, 7, 5, 7, 7};
    rep(i, n){
        int p = 0, j = i;
        while(p < 5 && j < n){
            int cnt = len[p];
            for(; cnt && j<n; ++j){
                cnt -= v[j];
                if(cnt < 0) goto end;
            }
            ++p;
        }
        
        if(p == 5){
            cout << i+1 << endl;
            break;
        }
    end:;
    }
}

int main()
{
    int n;
    
    while(cin >> n, n){
        solve(n);
    }
}

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

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

using namespace std;

int n;
string w[50];
int limit[] = {5,7,5,7,7};

int main() {
  while( cin >> n, n ) {
    rep(i,n) cin >> w[i];
    rep(i,n) {
      int index = 0;
      int sum = 0;
      REP(j,i,n) {
	sum += (int)w[j].size();
	if( sum == limit[index] ) {
	  ++index;
	  sum = 0;
	  if( index >= 5 ) {
	    cout << i+1 << endl;
	    goto Fin;
	  }
	} else if( sum > limit[index] ) {
	  break;
	}
      }
    }
    Fin:;
  }
  return 0;
}

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

int main(){
	while(true){
		int n;
		cin>>n;
		
		if(n==0)
			break;
		
	int len[40];
	for(int i=0;i<n;i++){
		string w;
		cin>>w;
		
		len[i] = w.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++: #include <bits/stdc++.h>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
    int n;
    string s;
    int len[5] = {5,7,5,7,7};
    int count;
    int now;
    int ans;
    while(1){
        cin >> n;
        if(n==0) return 0;
        vector<int> w(n);
        for(int i=0;i<n;i++){
            cin >> s;
            w[i]=s.length();
        }
        ans=-1;
        for(int i=0;i<n;i++){
            count = 0;
            now = 0;
            for(int j=i;j<n;j++){
                count+=w[j];
                if(count==len[now]){
                    now++;
                    count=0;
                    if(now==5){
                        ans=i;
                    }
                }else if(count>len[now]){
                    break;
                }
            }
            if(ans != -1){
                break;
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}