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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
int a[1000];
int table[] = { 5,12,17,24,31,-1 };

int main() {
	while (cin >> n&&n) {
		rep(i, n) {
			string s;
			cin >> s;
			a[i] = s.size();
		}
		rep(i, n) {
			a[i + 1] += a[i];
		}
		rep(i, n) {
			int pos = 0;
			FOR(j, i, n) {
				if (i != 0) {
					if (table[pos] == a[j] - a[i - 1])pos++;
				}
				else {
					if (table[pos] == a[j])pos++;
				}
			}
			if (pos == 5) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

C++: #include<iostream>
#include<cstdio>

#define rep(i, n, m) for(int i=n;i<m;i++)

using namespace std;

const int num[5] = {5,7,5,7,7};

int main() {
    int n;
    while(scanf("%d", &n) && n){
        int a[n+1];
        rep(i, 0, n){
            string s;
            cin >> s;
            a[i+1] = s.length();
        }

        int ans = -1;
        rep(i, 1, n+1){
            int num_i = 0, cnt = 0;
            rep(j, i, n+1){
                cnt += a[j];
                if(num[num_i] == cnt){
                    num_i++;
                    cnt = 0;
                    if(num_i == 5){
                        ans = i;
                        break;
                    }
                }else if(cnt > num[num_i]){
                    break;
                }
            }
            if(ans != -1) break;
        }

        printf("%d\n", ans);
    }
}

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

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        int phraseCount[] = {5, 7, 5, 7, 7};
        int currentPhraseIndex = 0;
        int currentPhraseCount = 0;
        string phrases[n];
        for(int i = 0; i < n; i++){
            cin >> phrases[i];
        }
        bool foundAnser = false;
        for(int k = 0; k < n; k++){
        for(int i = k; i < n; i++){
            string s;
            s = phrases[i];
            currentPhraseCount += s.length();
            if(currentPhraseCount == phraseCount[currentPhraseIndex]){
                currentPhraseIndex++;
                currentPhraseCount = 0;
                if(currentPhraseIndex == 5){
                    cout << k + 1 << endl;
                    for(int j = i + 1; j < n; j++){
                        cin >> s;
                    }
                    foundAnser = true;
                    break;
                }
            }else if(currentPhraseCount > phraseCount[currentPhraseIndex]){
                currentPhraseIndex = 0;
                currentPhraseCount = 0;
                break;
            }
        }
        if(foundAnser){
            break;   
        }
        }
    }
    return 0;
}

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;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

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

void solve(int n){
	string s;
	vi v(n);
	rep(i,n){
		cin>>s;
		v[i]=s.size();
	}
	rep(i,n-4){
		int pos=i;
		int ku=0;
		int wo=0;
		while(pos<n&&ku<5){
			wo+=v[pos];
			pos++;
			if(wo==tk[ku]){
				ku++;
				wo=0;
			}
			else if(wo>tk[ku])break;
		}
		if(ku==5){
			cout<<i+1<<endl;
			return;
		}
	}

}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n)solve(n);
}