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>
using namespace std;
string S[1000]; int  n, p[5] = { 5,12,17,24,31 };
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)cin >> S[i];
		for (int i = 0; i < n; i++) {
			int cnt = 0, sum = 0;
			for (int j = i; j < n; j++) {
				if (cnt >= 5)continue;
				sum += S[j].size();
				if (p[cnt] == sum)cnt++;
			}
			if (cnt == 5) { cout << i + 1 << endl; break; }
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>

int n,len[40];
char word[11];

int solve(int pos) {
	int rest;
	rest = 5;
	while (rest > 0) {
		rest -= len[pos++];
		if (rest < 0)return 0;
	}
	rest = 7;
	while (rest > 0) {
		rest -= len[pos++];
		if (rest < 0)return 0;
	}
	rest = 5;
	while (rest > 0) {
		rest -= len[pos++];
		if (rest < 0)return 0;
	}
	rest = 7;
	while (rest > 0) {
		rest -= len[pos++];
		if (rest < 0)return 0;
	}
	rest = 7;
	while (rest > 0) {
			rest -= len[pos++];
			if (rest < 0) return 0;
	}
	return 1;
}

int main() {
	while (1) {
		scanf("%d\n", &n);
		for (int i = 0; i < n; i++) {
			scanf("%s\n", word);
			len[i] = strlen(word);
		}
		for (int j = 0; j < n; j++) {
			if (solve(j)) {
				printf("%d\n", j + 1);
				break;
			}
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;

int w[42]; // 1-origin
int n;
static const int secToNum[6] = {0, 5, 7, 5, 7, 7};

bool solve(int x) {
  int sum;
  for (int sec = 1; sec <= 5; sec++) {
    sum = 0;
    while (sum < secToNum[sec]) {
      sum += w[x];
      x++;
    }
    if (sum > secToNum[sec]) {
      return false;
    }
  }
  return true;
}

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

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

    for(int i = 1; i <= n; i++){
        if(solve(i))cout << i << endl;
        break;
    }
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int a[10]={5,7,5,7,7};

void f(int n){
  string s[100];
  rep(i,n){
    cin>>s[i];
  }

  rep(i,n){
    int k=0;
    int t=0;
    FOR(j,i,n){
      t+=s[j].length();
      if(t==a[k]){
        k++;
        t=0;
      }
    }
    if(k==5){
      cout<<i+1<<endl;
      return;
    }
  }
}



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

  return 0;
}

C++: /*** ?????\ ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int N;
	while(cin>>N, N){
		int len[41]={};
		REP(i, 0, N){
			string s;
			cin >> s;
			len[i]=s.size();
		}
		
		REP(i, 0, N){
			int num=0;
			int haiku[5]={5, 7, 5, 7, 7};
			bool flag=false;
			
			REP(j, i, N){
				haiku[num]-=len[j];
				if(haiku[num]<0) break;
				if(haiku[num]==0) num++;
				if(num==5){
					flag=true;
					break;
				}
			}
			
			if(flag){
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

bool isHaiku(vector<string>::iterator t){
  
  int count;
  string s;

  count = 0;
  while(count < 5){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>5)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  count = 0;
  while(count < 5){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>5)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  return true;

}

int main(){

  vector<string> s(0);
  int n;

  while( cin >> n , n){
    s.resize(n);
    for(int i=0; i<n;i++)cin>>s[i];
   
    // for(int i=0; i<n;i++)cout<<s[i]<<' ';

    int indx=0;
    while(isHaiku(s.begin()+indx)==false ){ indx++; }

    cout << indx+1 << endl;

  }


  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        vector<int> W;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            W.push_back(s.size());
        }
        // cout<<n<<endl;
        int C[5]={5,7,5,7,7};
        for(int i=0;i<n;i++){
            bool done = false;
            for(int j=i,c=0,cnt=0;j<n;j++){
                cnt+=W[j];
                // cout<<cnt<<endl;
                if(cnt<C[c]) continue;
                else if(cnt==C[c]){
                    c++;
                    cnt=0;
                    if(c==5){
                        cout<<i+1<<endl;
                        done = true;
                        break;
                    }
                }else{
                    break;
                }
            }
            if(done) break;
        }
    }
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int num[5]={5,7,5,7,7},n,cnt=0,step,size,ie,f=0;
  string s[40];
  cin >> n;
  while(n!=0){
    cnt=0;
    step=0;
    for(int i=0;i<n;i++){
      cin >> s[i];
    }
    for(int i=0;i<n;i++){
      f=0;
      ie=0;
      for(int j=0;j<5;j++){
        size=0;
        while(num[j]>size){
        size += s[i+ie].length();
          ie++;
        }
        if(num[j]!=size){
          f=1;
          break;
        }
      }
    if(f==0){
      cout << i+1<<endl;
      break;
    }
  }
  cin >> n;
}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
using namespace std;
typedef long long int ll;

int n;
int p[]={5,12,17,24,31};

void solve(){
	vector<int> a(n+1);
	for(int i=0;i<n;i++){
		string s; cin >> s;
		a[i+1]=a[i]+(int)s.size();
	}
	for(int i=0;i<n;i++){
		int j=0;
		for(int k=i+1;k<=n;k++){
			if(a[k]==a[i]+p[j]){
				j++;
				if(j==5)break;
			}
		}
		if(j==5){
			printf("%d\n",i+1 );
			return;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n==0)break;
		solve();
	}
}