Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		s := make([]string, n)
		for i := 0; i < n; i++ {
			s[i] = io.NextLine()
		}
		w := [5]int{5, 7, 5, 7, 7}
		ans := 0
	OUTER:
		for i := 0; i < n; i++ {
			cnt, wc := 0, 0
			for j := i; j < n; j++ {
				wc += len(s[j])
				if wc == w[cnt] {
					cnt++
					wc = 0
					if cnt == 5 {
						ans = i + 1
						break OUTER
					}
				} else if wc > w[cnt] {
					break
				}
			}
		}
		io.Println(ans)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

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

int N;
vector<int> A;
int table[] = {5, 7, 5, 7, 7};

int solve(){
    for(int i=0; i<N; i++){
        bool ok = true;
        int cur = i;
        for(int j=0; j<5; j++){
            int s = 0;
            while(cur<N && s<table[j]){
                s += A[cur++];
            }
            if(table[j] != s){
                ok = false;
                break;
            }
        }
        if(ok)
            return i+1;
    }
    return -1;
}

int main(){
    while(cin >> N, N){
        A.clear();
        for(int i=0; i<N; i++){
            string s; cin >> s;
            A.push_back(s.size());
        }
        cout << solve() << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<math.h>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;

int main(){
  //std::ifstream in("test.txt");
  //  std::cin.rdbuf(in.rdbuf());
  int n;
  string inp;
  int set[5]={5,12,17,24,31};
  while(1){
    cin >> n;
    if(n==0)return 0;

    //int list[n];
    int shori[n];
    
    int size;
    int ans=0;
    //  int num=0;
    for(int i=0;i<n;i++){
      cin >> inp;
      if(ans==-1)continue;
      size=inp.size();
      shori[i]=0;
      //cout << list[i] << endl;
      for(int j=0;j<=i;j++){
	if(shori[j]==-1)continue;
       
        for(int l=0;l<5;l++){
	  if(shori[j]<set[l]){
	    if(size<=set[l]-shori[j]){
	      shori[j]+=size;
	      break;
	    }else{
	      shori[j]=-1;
	      break;
	    }
	  }
	}
	if(shori[j]==set[4]){
	  cout << j+1 << endl;
	  ans=-1;
	  break;
	}
      }
      
   
    }
 
  }
      
}

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    string w[n];
    for(int i = 0; i < n; ++i){
      cin >> w[i];
    }
    int phrase[] = {5,7,5,7,7};
    bool f = false;
    for(int i = 0; i < n; ++i){
      if(f) break;
      int s = 0, t = 5;
      for(int j = i; j < n; ++j){
	t -= w[j].size();
	if(!t){
	  ++s;
	  if(s == 5){
	    cout << i+1 << endl;
	    f = true;
	    break;
	  }
	  t = phrase[s];
	}else if(t < 0) break;
      }
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int solve(vector<int> &a)
{
    int N = a.size();
    const int p[] = {5, 7, 5, 7, 7};
    for (int i = 0; i < N; i++) {
        bool poss = 1;
        int q = i;
        for (int j = 0; j < 5; j++) {
            int sum = 0;
            for (; q < N; ) {
                sum += a[q++];
                if (sum >= p[j]) break;
            }
            if (sum != p[j]) {
                poss = 0;
                break;
            }               
        }
        if (poss) {
            return i + 1;
        }
    }
    return -1;
}

int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N);
        string s;
        for (int i = 0; i < N; i++) {
            cin >> s;
            a[i] = s.size();
        }
        cout << solve(a) << endl;
    }
    return 0;
}

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++: /* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s[40];

int main(){
  while (cin >> n, n){
    rep(i, n) cin >> s[i];
    rep(i, n){
      int m = (1 << 6) | (1 << 13) | (1 << 18) | (1 << 25) | (1 << 30);
      int b = 0;
      rep(j, i, n){
        b <<= s[j].size();
        b |= 1 << s[j].size() - 1;
        if ((b & m) == m){
          cout << i + 1 << endl;
          goto B;
        }
      }
      B:;
    }
  }
}