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>

using namespace std;

int main()
{
  int N;
  while (cin>>N, N) {
    vector<string> s(N);
    int num[] = {5, 7, 5, 7, 7};
    for (int i=0; i<N; i++) cin>>s[i];
    
    
    for (int i=0; i<N; i++) {
      bool ok=true;
      int idx=i;

      for (int j=0; j<5; j++) {
        int len = s[idx].size();
        ++idx;
        while (idx<N && len<num[j]) len+=s[idx++].size();

        if(idx > N) {
          ok = false;
          break;
        }
        
        if (len != num[j]) {
          ok=false;
        }
      }

      if (ok) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}

C++: main(){puts("hoge");}

C++: #include <iostream>
#include <vector>
#include <string>
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.size();
		}

		for(int i=0;i<n;i++){
			int count=0;
			int j=i;
			vector<bool> ok(5,false); 
			while(j<=n-1){
				count+=v[j];
				j++;
				if(count==5)ok[0]=true;
				if(ok[0] && count==12)ok[1]=true;
				if(ok[1] && count==17)ok[2]=true;
				if(ok[2] && count==24)ok[3]=true;
				if(ok[3] && count==31)ok[4]=true;
				if(ok[4]){
					cout<<i+1<<endl;
					goto END;
				}
			}
		}
		END:;
	}
}

C++: #include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
vector<int> v;
int f(int a){
    int t[5]={5,7,5,7,7};
    cnt=0;
    while(1){
        t[cnt]-=v[a];
        if(t[cnt]==0)cnt++;
        else if(t[cnt]<0)return 0;
        a++;
        if(cnt==5)return a+1;
    }
}
int main(void){
    while(1){
    cin>>n;
    v={};
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin>>s;
        v.push_back(s.size());
    }
    for(int i=0;i<n;i++){
        ans=f(i);
        if(ans!=0){
            cout<<i+1<<endl;
            break;
        }
    }
    }
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    vector<int> val;

    void input() {

    }

    bool check(int s) {
        vector<int> tanka{5, 7, 5, 7, 7};
        vector<int> v(5);
        int pt = 0;

        for (int i = s;; ++i) {
            v[pt] += val[i];
            if (v[pt] == tanka[pt]) {
                pt++;
            } else if (v[pt] > tanka[pt]) {
                return false;
            }

            if (pt == 5) {
                return true;
            }
        }

    }

    bool solve() {
        input();
        int n;
        cin >> n;
        if (n == 0) return false;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            val.push_back(s.size());
        }

        for (int i = 0; i < n; ++i) {
            if (check(i)) {
                cout << i + 1 << endl;
                return true;
            }
        }

        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve()) {}

    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)

bool solve() {

	int n; cin >> n;
	if (n == 0)return false;

	vector<string> w(n);
	REP(i, 0, n)cin >> w[i];

	REP(i, 0, n)
	{
		list<int> mojisu{5,7,5,7,7};
		REP(j, i, n)
		{
			mojisu.front()-=w[j].length();
			if (mojisu.front() == 0)
			{
				mojisu.pop_front();
				if (mojisu.empty())
				{
					cout << i + 1 << endl;
					return true;
				}
			}
			else if(mojisu.front() < 0)
			{
				break;
			}
		}
	}
}

signed main() {
	while (solve()) {
	}
	return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int N;
vector<int> v;

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

bool saiki(int pos, int num = 0,int state = 0)
{
	if (pos == (int) v.size()) return false;
	num += v[pos];
	if (tanka[state] < num) return false;
	if (tanka[state] == num) {
		state++;
		num = 0;
	}
	if (state == 5) return true;
	return saiki(pos+1, num, state);
}

int main()
{
	cin >> N;
	while(N) {
		rep(i, N) {
			string s;
			cin >> s;
			v.PB(s.length());
		}
		rep(i, N) {
			if (saiki(i)) {
				cout << i+1 << endl;
				break;
			}
		}
		cin >> N;
		v.clear();
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
while(1){
ll n;
cin >>n;
if(n==0){
break;
}
string name[n];
REP(i,n){
cin>>name[i];
}
ll num[n];
REP(i,n){
num[i]=name[i].length();
}

REP(i,n){
ll len=0;
ll now=i;
while(len<5){
len+=num[now];
now++;
}

if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<5){
len+=num[now];
now++;
}
if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
cout<<i+1;
break;
}
}
}

}
}

}





}


return 0;
}