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;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,k,n) for(int i=(int)(k);i<(int)(n);i++)

#define vi vector<int>
#define pb push_back

int main(){
//    ifstream in("b_in.txt");
//    cin.rdbuf(in.rdbuf());
    int n;
    while(cin >> n,n){
        string w[50];
        int l[50];
        rep(i,n) cin >> w[i];
        l[0] = 0;
        REP(i,1,n+1) {
            l[i] = l[i-1] + w[i-1].size();
        }

        REP(jj, 1, n) {
            bool finished = false;
            rep(ii, jj) {
                bool muri = false;
                int base = l[jj];
                int cur = jj+1;
                if(l[jj] - l[ii] == 5) {
                    for(; cur<n; cur++) {
                        if(l[cur] == base+7) break;
                        else if(l[cur] > base+7) {
                            muri = true;
                            break;
                        }
                    }
                    if(muri) break;
                    cur++;

                    for(; cur<n; cur++) {
                        if(l[cur] == base+12) break;
                        else if(l[cur] > base+12) {
                            muri = true;
                            break;
                        }
                    }
                    if(muri) break;
                    cur++;

                    for(; cur<n; cur++) {
                        if(l[cur] == base+19) break;
                        else if(l[cur] > base+19) {
                            muri = true;
                            break;
                        }
                    }
                    if(muri) break;
                    cur++;

                    for(; cur<n+1; cur++) {
                        if(l[cur] == base+26) {
                            cout << ii+1 << endl;
                            finished = true;
                            break;
                        }
                        else if(l[cur] > base+26) {
                            break;
                        }
                    }
                }
            }
            if(finished) break;
        }
    }

    return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cassert>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
//typedef pair<int, int> pii;
using pll = pair<ll, ll>;
using pii = pair<short, short>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define rep1(i,a) for(int i=1;i<=(a);i++)
#pragma warning(disable:4996)
//#define INF 1000000000000000.0
int main() {
	int n;
	while (cin >> n, n) {
		vector<int> num;
		string buf;
		rep(i, n) {
			cin >> buf;
			num.push_back(buf.length());
		}
		rep(i, n) {
			vi sp(5);
			int pos = 0;
			bool f = 1;
			for (int j = i;; j++) {
				f = 1;
				sp[pos] += num[j];
				if (sp[pos] > (pos & 5 ? 7 : 5)) {
					f = 0;
					break;
				}
				if (sp[pos] == (pos & 5 ? 7 : 5)) {
					pos++;
					if (pos == 5)break;
				}
			}
			if (f) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

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=1;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>
#include <vector>
#include <algorithm>
#include <utility>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define INF 2000000000



using namespace std;
int main(void){
    while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<int> v;
    
    rep(i,0,n){
        string s;
        cin>>s;
        v.push_back(s.length());
    }
    
    
    
    rep(i,0,n){
        int count=0,sum=0;
        rep(j,i,n){
            sum+=v[j];
            if(count==0){
               if(sum==5)count=1;
               else if(sum>5)break;
            }
            else if(count==1) {
                if(sum==12) count=2;
                else if(sum>12)break;
            }else if(count==2) {
                if(sum==17) count=3;
                else if(sum>17)break;
            }else if(count==3) {
                if(sum==24) count=4;
                else if(sum>24)break;
            }else if(count==4) {
                if(sum==31){
                    count=5;
                    cout<<i+1<<endl;
                    goto Away;
                }
                else if(sum>31)break;
            
            } 
        }    
    }
    cout<<"j"<<endl;
    Away:;
    }
    return 0;
}