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<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

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

int main()
{	
	int n;
	
	while(cin >> n,n)
	{
		vector<string> v;
		REP(i,n)
		{
			string tmp;cin >> tmp;
			v.PB(tmp);
		}
		
		REP(i,n)
		{
			int cou = 0;
			int num = 0;
			for(int j = i;j < n;j++)
			{
				num += v[j].size();
				if(num == ok[cou])
				{
					cou++;
					num=0;
					if(cou == 5)
					{
						cout << i+1 << endl;
						goto NEXT;
					}
					
				}
				else if(num > ok[cou])
				{
					break;
				}
			}
		}
		NEXT:;
	}
			
			
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <algorithm>
#include <math.h>

using namespace std;

string w[41];
int n,ans;
int d=0;
int solve(){
    for(int i=0;i<n;i++){
    int a=0;
    d=0;
        for(int j=i;j<n;j++){
            a+=w[j].length();
            if(d==0&&a==5){
            d++;
            a=0;
            }
            if(d==1&&a==7){
             d++;
            a=0;
            }
            if(d==2&&a==5){
             d++;
            a=0;
            }
            if(d==3&&a==7){
             d++;
            a=0;
            }
            if(d==4&&a==7){
            ans=i+1;
            return i;
            }
            if(a>7)break;
        }
    }
    return 0;
}
int main()
{
    while(1){
    cin>>n;
    if(n==0)return 0;
    for(int i=0;i<n;i++)
    cin>>w[i];
    
    d=0;
    solve();
    cout<<ans<<endl;
    }
}

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

  int n,w[430];
  string str,kari;

  cin >> n;
  while( n != 0){
    fill_n(w,430,0);
    w[0] = 1;

    for(int i = 0;i < n;i++){
      cin >> kari;
      if(i != 0) w[str.size()] = i+1;
      str += kari;
    }
    w[str.size()]=n+1;
    
    for(int i = 0;i <= str.size()-31;i++){
      if(w[i]!=0&&w[i+5]!=0&&w[i+12]!=0&&w[i+17]!=0&&w[i+24]!=0&&w[i+31]!=0){
	cout << w[i] << endl;
	break;
      }
    }
    cin >> n;
  }
  return (0);
}

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

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

int main(){
    int n;
    while(scanf("%d",&n), n != 0){
        string w[40];
        for(int i=0;i<n;++i)cin >> w[i];
        for(int i=0;i<n;++i){
            int k=0, cnt=0, j=i;
            while(k < 5 && j < n){
                cnt += w[j].size();
                if(cnt > tanku[k])break;
                if(cnt == tanku[k]){
                    ++k;
                    cnt = 0;
                }
                ++j;
            }
            if(k == 5){
                printf("%d\n",i+1);
                break;
            }
        }
    }

    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int make(int w,int p);

vector<string> a(50);

int main() {
  int n;
  scanf ("%d",&n);
  while(n){

    for(int t=0;t<n;t++){
      //scanf ("%s",a[t]);
      cin >> a[t];
    }
    for(int t=n;t<50;t++){
      //scanf ("%s",a[t]);
      a[t]="";
    }
    int end=0;
    int k=0;
    for(k=0;k<n;k++){
      int q=k;
      if(make(q,5)>=1){
        q=1+make(q,5);
        if(make(q,7)>=1){
          q=1+make(q,7);
          if(make(q,5)>=1){
            q=1+make(q,5);
            if(make(q,7)>=1){
              q=1+make(q,7);
              if(make(q,7)>=1){
                end=1;
                //printf("qwqw\n");
              }
            }
          }
        }
      }
      if(end==1) break;
    }
    printf("%d\n",k+1);
    scanf ("%d",&n);
  }
}


int make(int w,int p){
  int l=a[w].size();
  int r=0;
  if(l==p){
    return w;
  }
  else{
    if(l<p){
      r=make(w+1,p-l);
      //printf("%d\n",r);
      return r;
    }
    else{
      return -1;
    }
  }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str[40];

void solve(){
	rep(i,n) cin >> str[i];
	rep(i,n){
		int cnt[5] = {5,7,5,7,7};
		for(int j = i; j < n; j++){
			rep(k,5){
				if(cnt[k] != 0){
					cnt[k] -= str[j].size();
					break;
				}
			}
		}
		bool ok = true;
		rep(j,5) if(cnt[j] != 0) ok = false;
		if(ok) cout << i+1 << endl;
	}
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

C++: #include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


bool read(const vector<int>& w, const int siz, int& now)
{
	const int n = w.size();
	int cnt = 0;
	while (now < n && cnt<siz) {
		cnt += w[now];
		now++;
	}
	return (cnt == siz);
}

//計算
void calc(vector<int> w)
{
	int n = w.size();
	REP(start, n) {
		int now = start;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 7, now))continue;
		//cerr << "answer     ";
		cout << start + 1 << endl;
		return;
	}
	//cout << "ERROR" << endl;
}



//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true) {
		int n;
		vector<int> w;
		string tmp;
		cin >> n;
		if (n == 0)break;
		REP(i, n) {
			cin >> tmp;
			w.push_back(tmp.size());
		}
		calc(w);
	}
	//debug();
	
	return 0;
}