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>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

bool check(vector<string> w, int begin) {
	bool res;
	int cur = begin;
	int buf = 0;
	int i = 0;
	vector<int> hoge = {5,7,5,7,7};
	for(i = 0; i < hoge.size() && cur < w.size(); cur++) {
		buf += w[cur].size();
		if(buf == hoge[i]) {
			buf = 0;
			i++;
		}
		if(buf > hoge[i]) {
			break;
		}
	}
	if(i == 5) {
		return true;
	}
	else {
		return false;
	}
}

int main(void){
	int n;
	while(cin>>n,n) {
		vector<string> W(n);
		rep(i,n) cin >> W[i];
		rep(i,n) {
			if(check(W, i-1)) {
				cout << i << endl;
				break;
			}
		}
	}
        
	return 0;
}

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

using namespace std;

int n;

int main(){
    while(1){
        cin >> n;
        if(n==0)break;
        vector<string> w(n);
        int tan[] = {5,7,5,7,7};
        for(int i=0;i<n;i++){
            cin >> w[i];
        }
        int j=0;
        int ans=0;
        int sum=0;
        for(int k=0;k<n;k++){
            sum=0;
            ans=k;
            j=0;
            for(int i=k;i<n;i++){
                sum += w[i].size();
                if(sum > tan[j]){
                    sum = w[i].size();
                    j=0;
                    ans=i;
                }
                if(sum < tan[j])continue;
                if(sum == tan[j]){
                    if(j==4)break;
                    else {
                        j++;
                        sum = 0;
                    }
                }
            }
            if(j==4 && sum == tan[j])break;
        }
        cout << ans+1 << endl;

    }
}

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

int main(){
  vector<int> num = {5, 7, 5, 7, 7};
  int n;
  while(std::cin >> n, n){
    vector<string> vs(n);
    for (int i = 0; i < n; i++) std::cin >> vs[i];
    for (int i = 0; i < n; i++) {
    int sum = 0, pos = 0;
      for (int j = i; j < n; j++) {
        sum += vs[j].size();
        if(sum == num[pos])sum = 0, pos++;
        if(pos == 5){
          std::cout << i + 1 << std::endl;
          i = j = 1e9;
        }
      }
    }
  }
  return 0;
}

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

int main(){
  int a,sum,k,l,sta,suc,h[50],han[5]={5,7,5,7,7};
  string s;
  while(cin>>a){
    if(a==0)break;
    for(int i=0;i<a;i++){
      cin>>s;
      h[i]=s.size();
    }
    suc=0;
    for(int i=0;i<a;i++){
      sum=0;k=0;l=0;
      while(1){
	sum+=h[i+k];
	  if(sum==han[l]){
	    l++;
	    sum=0;
	  }else if(sum>han[l])break;
	if(l==5){
	  suc=1;
	  break;
	}
	k++;
	if(k>=a)break;
      }
      if(suc==1){
	sta=i;
	break;
      }
    }
    cout<<sta+1<<endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll table[] = {5,7,5,7,7};

int main(){
    while(cin >> n && n){
        vector<ll> v(n);
        rep(i,n){
            string s;
            cin >> s;
            v[i] = s.size();
        }
        rep(i,n){
            bool ok = true;
            ll cnt = 0;
            ll pos = 0;
            FOR(j,i,n){
                cnt += v[j];
                if(cnt > table[pos])ok = false;
                else if(cnt == table[pos]){
                    pos++;
                    cnt = 0;
                }
                if(pos == 5)break;
            }
            if(ok){
                cout << i+1 << endl;
                break;
            }
        }
    }
}