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 <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll t[5] = {5,7,5,7,7};

int main(){
	while(1){
		ll n; cin >> n;
		if(!n) break;
		vs s(n);
		rep(i,n) cin >> s[i];
		rep(i,n){
			ll now = 0;
			ll rest = 5;
			for(ll j=i; j<n; j++){
				if(s[j].size() > rest) break;
				else if(s[j].size() == rest){
					now++;
					if(now < 5) rest = t[now];
				}else{
					rest -= s[j].size();
				}
				if(now == 5) break;
			}
			if(now == 5){
				cout << i+1 << endl;
				break;
			}
		}
	}
}

C++: #include<bits/stdc++.h>
#define N 45
using namespace std;
int n,l[N],L[N],ans;
int d[5]={5,7,5,7,7};
string s;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=1;i<=n;i++){
      cin>>s,l[i]=s.size();
      L[i]=L[i-1]+l[i];
    }
    ans=0;
    for(int i=1;i<=n-6;i++){
      int idx=0,s=i;
      for(int j=i;j<=n;j++){
	if(L[j]-L[s-1]==d[idx])idx++,s=j+1;
	if(!ans&&idx==5)ans=i;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int haiku[5] = {5,7,5,7,7};
  int n;
  while(cin>>n,n){
    vector<string> vs(n);
    FOR(i,0,n) cin >> vs[i];
    FOR(i,0,n) {
      int j = 0;
      int k = i;
      while(k < n && j < 5) {
        int len = 0;
        while(len < haiku[j] && k < n) {
          len += vs[k].length();
          k++;
        }
        if(len != haiku[j]) break;
        j++;
      }
      if(j == 5) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        vector<int>v(n);
        for(int i=0;i<n;++i){
            string s;
            cin>>s;
            v[i]=s.length();
        }
        for(int i=0;i<n;++i){
            int a=0,b=0,c=0,d=0,e=0,j=i;
            bool flag=0;
            while(a<5){
                a+=v[j++];
                if(a==5){
                    while(b<7){
                        b+=v[j++];
                        if(b==7){
                            while(c<5){
                                c+=v[j++];
                                if(c==5){
                                    while(d<7){
                                        d+=v[j++];
                                        if(d==7){
                                            while(e<7){
                                                e+=v[j++];
                                                if(e==7){
                                                    cout<<i+1<<endl;
                                                    flag=1;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if(flag)break;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int n, t, x, j;
  string s;
  vector<int> v, u;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      cin >> s;
      v.push_back(s.size());
    }
    t = 0;
    u = {5, 7, 5, 7, 7, 0};
    for (int i = 0; i < n; ++i) {
      j = i;
      t = 0;
      x = 5;
      while (x >= 0 && t < 5) {
	x -= v[j];
	if (!x) {
	  ++t;
	  x = u[t];
	} else if (x < 0) break;
	++j;
      }
      if (t == 5) {
	cout << i+1 << endl;
	break;
      }
    }
    v.erase(v.begin(), v.end());
  }
  return 0;
}

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

int N;
vector<int> A;
int table[] = {5, 7, 5, 7, 7};

int solve(){
    for(int i=0; i<N; i++){
        bool ok = true;
        int cur = i;
        for(int j=0; j<5; j++){
            int s = 0;
            while(cur<N && s<table[j]){
                s += A[cur++];
            }
            if(table[j] != s){
                ok = false;
                break;
            }
        }
        if(ok)
            return i+1;
    }
    return -1;
}

int main(){
    while(cin >> N, N){
        A.clear();
        for(int i=0; i<N; i++){
            string s; cin >> s;
            A.push_back(s.size());
        }
        cout << solve() << endl;
    }
    return 0;
}