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 MOD 1000000007LL
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int n;
int cnt[101];
int cal[5]={5,7,5,7,7,};

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			cnt[i]=str.size();
		}
		int res=-1;
		for(int i=0;i<n;i++){
			if(res!=-1)continue;
			int now=0;
			int len=0;
			for(int j=i;j<n;j++){
				len+=cnt[j];
				if(len==cal[now]){
					now++;
					len=0;
				}else if(len>cal[now]){
					break;
				}
				if(now==5){
					res=i;
					break;
				}
			}
		}
		printf("%d\n",res+1);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int f(vector<string> &s, int cur, int L){
    int len = 0, ret = 0;
    while(cur < s.size() && len < L){
        len += s[cur].size();
        ++cur;
        ++ret;
    }
    return len == L ? ret : -1;
}

int main(){
    int n;
    while(scanf("%d", &n) && n){
        vector<string> s(n);
        for(auto &i: s) cin >> i;
        vector<int> a(n), b(n);
        rep(i, n){
            a[i] = f(s, i, 5);
            b[i] = f(s, i, 7);
        }
        int ans;
        rep(i, n){
            int cur = i;
            if(a[cur] < 0) continue;
            cur += a[cur];
            if(b[cur] < 0) continue;
            cur += b[cur];
            if(a[cur] < 0) continue;
            cur += a[cur];
            if(b[cur] < 0) continue;
            cur += b[cur];
            if(b[cur] < 0) continue;
            cur += b[cur];
            ans = i;
            break;
        }
        printf("%d\n", ans+1);
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
bool check575(vector<int> &v,int pos) {
    int sum;
    sum=0;
    while(pos<v.size()&&sum<5) sum+=v[pos++];
    if(sum!=5) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    sum=0;
    while(pos<v.size()&&sum<5) sum+=v[pos++];
    if(sum!=5) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    return 1;
}
int main() {
    int n;
    string w;
    while(cin>>n,n) {
        vector<int> v;
        for(int i=0;i<n;i++) {
            cin>>w;
            v.push_back(w.size());
        }
        for(int i=0;i<v.size();i++) {
            if(check575(v,i)) {
                printf("%d\n",i+1);
                break;
            }
        }
    }
}

C++: #include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		string s[n];
		int num[n];
		rep(i,n)cin>>s[i];
		rep(i,n)num[i]=s[i].size();
		rep(i,n){
			int check=0,sum=0;
			for(int j=i;sum<=31;j++){
				sum+=num[j];
				if(sum==5)check|=1;
				else if(sum==12)check|=(1<<1);
				else if(sum==17)check|=(1<<2);
				else if(sum==24)check|=(1<<3);
				else if(sum==31)check|=(1<<4);
			}
			if(check==(31)){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	return 0;

}