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 <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;;

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> a(n);
        rep(i, 0, n){
            string s;
            cin >> s;
            a[i] = s.size();
        }
        int d[6] = {5, 7, 5, 7, 7, 114514};
        int ans = -1;
        rep(i, 0, n){
            int now = 0;
            int tmp = 0;
            rep(j, i, n){
                if(a[j] + tmp < d[now]){
                    tmp += a[j];
                }else if(a[j] + tmp == d[now]){
                    now++;
                    tmp = 0;
                }else{
                    break;
                }
                // cout << now << " " << tmp << endl;
                if(now == 5){
                    cout << i + 1 << endl;
                    i = n;
                    break;
                }
            }
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
int n;
int tanku[]={5,7,5,7,7};
while(1){
cin>>n;
if(n==0)break;
string a;
vector<int> w(n);
for(int i=0;i<n;i++){
	cin>>a;
	w[i]=a.size();
}
int plase;
for(int i=0;i<n;i++){
plase=i;
int sum=0;
int k=0;
bool flag=false;
for(int j=i;j<n;j++){
sum+=w[j];
if(sum>tanku[k])break;
if(sum==tanku[k]){
	k++;
	sum=0;
}
if(k==5){
	flag=true;
	break;
}
}
if(flag){
	cout<<i+1<<endl;
	break;
}
}
}	
return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> n;
        if (n == 0) break;
        string s[45];
        rep(i, n) cin >> s[i];
        int ans = 0;
        rep(i, n) {
            bool go = false;
            int k = i;
            bool ok[5] = {};
            while (k < n) {
                int cnt = 0;
                bool check = false;
                int num = 0;
                int idx = 0;
                rep(l, 5) {
                    if (!ok[l]) {
                        check = true;
                        if (l == 4) {
                            idx = l;
                            num = 7;
                            break;
                        }
                        else if (l % 2 == 0) {
                            idx = l;
                            num = 5;
                            break;
                        }
                        else {
                            idx = l;
                            num = 7;
                            break;
                        }
                    }
                }
                if (!check) {
                    go = true;
                    break;
                }
                bool back = false;
                while (k < n) {
                    cnt += s[k].size();
                    k++;
                    if (cnt == num) {
                        ok[idx] = true;
                        break;
                    }
                    else if (cnt > num) {
                        back = true;
                        break;
                    }
                }
                if (back) break;
                check = false;
                rep(l, 5) if (!ok[l]) check = true;
                if (!check) {
                    go = true;
                    break;
                }
            }
            if (go) {
                ans = i + 1;
                break;
            }
        }
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
#define f(X) for(c=0;c<X;c+=v[p++]);if(c-X)goto L;
main(){for(char n,v[99],s,p,c;n=atoi(gets(v));){for(s=0;s<n;v[++s]=strlen(gets(v+n)));s=0;L:p=++s;f(5)f(7)f(5)f(7)f(7)printf("%d\n",s);}}