Go: // Short Phrase(短句)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1601&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		n := nextInt(sc)
		if n == 0 {
			break
		}

		var words []string
		for i := 0; i < n; i++ {
			words = append(words, nextString(sc))
		}

		res := 0
		for i := 0; i < n; i++ {
			tmpWords := words[i:]
			ok := checkRule(tmpWords, 0)
			if ok {
				res = i + 1
				break
			}
		}

		fmt.Println(res)
	}
}

var rule = [5]int{5, 7, 5, 7, 7}

func checkRule(words []string, depth int) bool {
	var shortPhrase = ""
	var i = depth

	if depth == 5 {
		return true
	}

	for len(words) > 0 {
		shortPhrase += words[0]
		words = words[1:]

		if rule[i] == len(shortPhrase) {
			return checkRule(words, i+1) // 短句のルールを満たしたので次の文節へ
		} else if rule[i] < len(shortPhrase) {
			return false // 文節の語数オーバー
		}
	}

	return false // 文節を満たす単語が足りない
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n;
    int length[5] = {5, 7, 5, 7, 7};
    while(cin >> n, n) {
        vector<int> v(n);
        REP (i, 0, n) {
            string str;
            cin >> str;
            v[i] = str.size();
        }
        int ans = -1;
        REP (i, 0, n) {
            int pos = 0;
            int total = 0;
            REP (j, i, n) {
                total += v[j];
                if (length[pos] == total) {
                    pos++;
                    total = 0;
                } else if (length[pos] < total) {
                    break;
                }
                if (pos == 5) {
                    ans = i + 1;
                    break;
                }
            }
            if (ans != -1) break;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n){
        vector<int> len(n);
        rep(i,n){
            string s;cin >> s;
            len[i]=s.size();
        }
        for(int i=0;i<n;i++){
            int now = i;
            int sum=0;
            while(sum<5){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=5)continue;
            
            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=7)continue;
            
            sum=0;
            while(sum<5){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=5)continue;
            
            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=7)continue;

            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(sum!=7)continue;
            cout << i+1 << endl;
            break;
        }

    }
    return 0;
}

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

using namespace std;

bool judge(int* a)
{
    int x[5] = {5, 7, 5, 7, 7};
    int i = 0;
    while(true)
    {
        if(i==5) return true;
        x[i] -= *a++;
        if(x[i]<0) return false;
        if(x[i]==0) i++;
    }
}

int main()
{
    int n;
    while(cin >> n, n)
    {
        int a[n];
        for(int i=0; i<n; i++)
        {
            string s;
            cin >> s;
            a[i] = s.size();
        }
        for(int i=0; i<n; i++)
        {
            if(judge(a+i))
            {
                cout << i+1 << endl;
                break;
            }
        }
    }
}

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 <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> v;

bool solve(int a){
	int i = a;
	int res = 0;
	while(i < v.size()){
		res += v[i].size();
		i++;
		if(res == 5){
			while(i < v.size()){
				res += v[i].size();
				i++;
				if(res == 12){
					while(i < v.size()){
						res += v[i].size();
						i++;
						if(res == 17){
							while(i < v.size()){
								res += v[i].size();
								i++;
								if(res == 24){
									while(i < v.size()){
										res += v[i].size();
										i++;
										if(res == 31)return true;
										else if(res > 31)return false;
									}
								}
								else if(res > 24)return false;
							}
						}
						else if(res > 17)return false;
					}
				}
				else if(res > 12)return false;
			}
		}
		else if(res > 5)return false;
	}
	return false;
}

int main(){
	int n;
	string s;
	while(cin >> n,n){
		v.clear();
		for(int i = 0;i < n;i++){
			cin >> s;
			v.push_back(s);
		}
		for(int i = 0;i < n;i++){
			if(solve(i)){
				cout << i+1 <<endl;
				break;
			}
		}
	}
	return 0;
}