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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cassert>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
//typedef pair<int, int> pii;
using pll = pair<ll, ll>;
using pii = pair<short, short>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define rep1(i,a) for(int i=1;i<=(a);i++)
#pragma warning(disable:4996)
//#define INF 1000000000000000.0
int main() {
	int n;
	while (cin >> n, n) {
		vector<int> num;
		string buf;
		rep(i, n) {
			cin >> buf;
			num.push_back(buf.length());
		}
		rep(i, n) {
			vi sp(5);
			int pos = 0;
			bool f = 1;
			for (int j = i;; j++) {
				f = 1;
				sp[pos] += num[j];
				if (sp[pos] > (pos & 5 ? 7 : 5)) {
					f = 0;
					break;
				}
				if (sp[pos] == (pos & 5 ? 7 : 5)) {
					pos++;
					if (pos == 5)break;
				}
			}
			if (f) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

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

int main(){
  while(1){
    int word[5]={5,7,5,7,7},n;
  cin>>n;
  if(n==0) break;
  string str[41];
  for(int i=1;i<=n;i++)
    cin>>str[i];
  for(int i=1;i<n;i++){
    int x=0,cnt=str[i].size();
    if(cnt==word[x])x++,cnt=0;
    for(int j=i+1;j<=n;j++){
      cnt+=str[j].size();
      if(cnt==word[x])x++,cnt=0;
      if(x==5) break;
    }
      if(x==5){cout<<i<<endl;break;}
  }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
    int n;
    cin >> n;

    while(n != 0) {
        vector<string> w(n);
        for (int i = 0; i < n; ++i) {
            cin >> w[i];
        }

        for (int j = 0; j < n; ++j) {
            int w_count = 0;
            int cur = j;

            while (w_count < 5 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 5) continue;

            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            w_count = 0;
            while (w_count < 5 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 5) continue;


            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            w_count = 0;
            while (w_count < 7 and cur < n) {
                w_count += w[cur].size();
                cur++;
            }
            if (w_count != 7) continue;

            cout << j+1 << endl;
            break;
        }
        cin >> n;

    }
}

C++: // 2018/01/05 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		string w[40];
		int len[40];
		for(int i=0; i<n; i++){
			cin >> w[i];
			len[i] = w[i].size();
		}

		for(int i=0; i<n; i++){
			bool flg = false;
			int sta = 0;
			int sum = 0;

			for(int j=i; j<n; j++){
				sum += len[j];

				if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
					sta++;
				}

				if(sta==5){
					flg = true;
					break;
				}
				else if(sum>=31){
					break;
				}
			}

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

	return 0;
}

C++: v[50],p,n,k,X;main(s){for(;n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;n;)for(n=0,p=++s,k=261096;k/=8;n+=X)for(X=k&7;X>0;X-=v[p++]);}}

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

using std::cin;
using std::cout;
using std::endl;

bool check_tanku(std::vector<std::string> v, int ind) {
	int piv = 0;
	int n = v.size();
	int l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}

	return true;
}

int main(void) {
	int n;
	int limit = 31;
	cin >> n;

	while ( n != 0 ) {
		std::vector<std::string> tan(n);
		std::vector<int> len(n,0);
		bool find = false;
		for (int i = 0; i < n; i++) {
			cin >> tan[i];
		}

		for (int i = 0; i < n; i++) {
			for (int j = i; j < n && len[i] < limit; j++) {
				len[i] += tan[j].length();
			}
		}

		int temp;
		for (int i = 0; i < n && !(find); i++) {
			if (len[i] == limit) {
				if (check_tanku(tan,i)) {
					cout << i+1 << endl;
					find = true;
				}
			}
		}

		cin >> n;
	}

	return 0;
}