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<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


void f(int n){
  string s[100];
  int a[7]={5,7,5,7,7};
  rep(i,n){
    cin>>s[i];
  }
  rep(i,n){
    int p=0;
    int m=0;
    FOR(j,i,n){
      m += (int)s[j].length();
      if(m==a[p]){
        m=0;
        p++;
      }
    }
    if(p==5){
      cout<<i+1<<endl;
      break;
    }
  }
}



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

  return 0;
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> p(n);
    REP(i,n) cin >> p[i];
    REP(i,n){
      int tmp=0,count=0;
      FOR(j,i,n){
	tmp+=p[j].size();
	if(tmp==5||tmp==12||tmp==17||tmp==24||tmp==31) ++count;
	if(tmp>=31) break;
      }
      if(count==5){
	cout << i+1 << endl;
	break;
      }
    }
  }
}

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

vector<string> a(50);

void main(void){
  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;
    }
    k++;
    printf("%d\n",k);
    scanf ("%d",&n);
  }
}


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

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
int n;
int tanku[]={5,7,5,7,7};
while(1){
cin>>n;
if(n==0)break;
string a;
vector<int> w(n);
for(int i=0;i<n;i++){
	cin>>a;
	w[i]=a.size();
}
int plase;
for(int i=0;i<n;i++){
plase=i;
int sum=0;
int k=0;
bool flag=false;
for(int j=i;j<n;j++){
sum+=w[j];
if(sum>tanku[k])break;
if(sum==tanku[k]){
	k++;
	sum=0;
}
if(k==5){
	flag=true;
	break;
}
}
if(flag){
	cout<<i+1<<endl;
	break;
}
}
}	
return 0;
}

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

using VI = vector<long>;

long TMP[5] = {5, 7, 5, 7, 7};

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n) {
      VI ps;
      for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ps.push_back(s.size());
      }
      for (int first = 0; first < n; first++) {
        int diff = 0;
        bool legal = true;
        for (int k = 0; k < 5; k++) {
          int acc = 0;
          while (acc < TMP[k]) {
            acc += ps[first + diff];
            diff++;
          }
          if (acc > TMP[k]) {
            legal = false;
            break;
          }
        }
        if (legal) {
          cout << first+1 << endl;
          break;
        }
      }
    } else {
      return 0;
    }
  }
}

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

int main()
{
	int tanku[5] = { 5,7,5,7,7 };

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

		if (n == 0) {
			break;
		}

		vector<string> strings(n);

		for (int i = 0; i < n; i++) {
			cin >> strings[i];
		}

		int ans;

		for (int i = 0; i < n; i++) {
			bool flag = true;
			int cur = 0;
			int size = 0;

			for (int j = i; j < n; j++) {
				size += strings[j].size();

				if (size > tanku[cur]) {
					flag = false;
					break;
				}

				if (size == tanku[cur]) {
					cur++;
					size = 0;
					if (cur == 5) {
						break;
					}
				}
			}

			if (flag == true) {
				ans = i + 1;
				break;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

int k[5] = { 5,7,5,7,7 };
int main() {
	int a;
	while (cin >> a, a) {
		int b[40];
		for (int c = 0; c < a; c++) {
			string d; cin >> d;
			b[c] = d.length();
		}
		for (int i = 0; i < a; i++) {
			int x = 0, y = 0;
			for (int j = i; j < a; j++) {
				if (y + b[j] > k[x])break;
				else if (y + b[j] < k[x])y += b[j];
				else { 
					x++; y = 0;
				if (x == 5) { cout << i + 1 << endl; goto l; }
				}
			}
		}
	l:;
	}
}

C++: #include<iostream>
#include<string>
int a[40],n;
int haiku(int);
using namespace std;
int main(){
  while(1){
    string x;
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> x;
      a[i]=x.size();
    }
    int f;
    for(int i=0;i<n;i++){
      f=haiku(i);
      if(f==1){
	cout << i+1 << endl;
	break;
      }
    }
  }
  return 0;
}
int haiku(int x){
  int c=0,c2=0;
  for(int i=x;i<n;i++){
    c+=a[i];
    if(c2==0||c2==2){
      if(c<5)continue;
      else if(c==5){
	c=0;
	c2++;
	continue;
      }
      else return 0;
    }
    else{
      if(c<7)continue;
      if(c==7){
	c=0;
	c2++;
	if(c2==5)return 1;
	continue;
      }
      else return 0;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
using namespace std;
int n, m;
string s;
int main() {
	while (cin >> n, n) {
		vector<string> v;
		for (int i = 0; i < n; ++i) {
			string str; cin >> str;
			v.push_back(str);
		}
		int point = 0;
		int cnt = 0;
		int i = 0; int j = 0;
		while (i < n) {
			cnt += v[i].size();
			i++;
			if (point == 0||point == 2) {
				if (cnt == 5) {
					point++;
                    cnt=0;
				}
				else if (cnt > 5) {
					cnt = 0;
					point = 0;
					j++;
					i = j;
				}
			}
			else if (point == 1||point == 3||point == 4) {
				if (cnt == 7) {
					point++;
					cnt=0;
				}
				else if (cnt > 7) {
					cnt = 0;
					point = 0;
					j++;
					i = j;
				}
			}
			if (point == 5) {
                cout << j+1 << endl;
                break;
            }
		}
	}
}