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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

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

int main(){

  int n;
  while(true){
    cin >> n;
    if(n == 0) break;

    vector<int> v;
    REP(i,n){
      string s;
      cin >> s;
      v.pb(s.length());
    }

    for(int i = 0; i < n - 4; ++i){
      int sum, j = i;
      bool tanka = true;
      for(int idx = 0; idx < 5; ++idx){
        sum = a[idx];
        while(true){
          if(sum == v[j]){
            sum = 0;
            j++;
            break;
          }else if(sum > v[j]){
            sum -= v[j];
            j++;
          }else{
            tanka = false;
            break;
          }
        }
        if(!tanka){
          break;
        }
      }
      if(tanka){
        cout << i+1 << endl;
        break;
      }

    }
  }
  return 0;
}

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

int main()
{
	int n;
	string tmp;
	while (cin >> n, n) {
		vector<string> v;
		v.reserve(n);
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}
		int del = 0;
		int flag = 0;
		while (flag != 5) {
			flag = 0;
			int length = 0;
			for (int i = del;i < v.size();i++) {
				length += v[i].size();
				if (length == 5 || length == 12 || length == 17 || length == 24 || length == 31)
					flag++;
			}
			del++;
		}
		cout << del << endl;
	}
	return 0;
}

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

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

		if (n == 0)
			break;

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

			len[i] = w.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++: #include<iostream>
#include<string>
using namespace std;
int n,w[450];
string str,kari;
int main(){

  cin >> n;
  while( n != 0){
    fill_n(w,450,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 <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);i++)

int main()
{
  int n;
  while(1){
    cin >> n;
    int w[n];
    if(n == 0) break;
    REP(i,n){
      string s;
      cin >> s;
      w[i]= s.size();
    }
    int c, x;
    REP(i,n){
      x = 0;
      for(int j = i; j < n && x < 5; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 5) continue;
      for(int j = c; j < n && x < 12; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 12) continue;
      for(int j = c; j < n && x < 17; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 17) continue;
      for(int j = c; j < n && x < 24; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 24) continue;
      for(int j = c; j < n && x < 31; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 31) continue;
      cout << i+1 << endl;
      break;
    }
  }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>ns(N);
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			ns[i] = st.size();
		}
		vector<int>ls(5);
		ls[0] = 5;
		ls[1] = 7;
		ls[2] = 5;
		ls[3] = 7;
		ls[4] = 7;
		for (int i = 0; i < N; ++i) {
			int now = 0;
			int num = 0;
			bool ok = false;
			for (int j = i; j < N; ++j) {
				num += ns[j];
				if (num > ls[now]) {
					ok = false;
					break;
				}
				else if (num == ls[now]) {
					now++;
					if (now == 5) {
						ok = true;
						break;
					}
					else {
						num = 0;
					}
				}
			}
			if (ok) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}