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 <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

        vector<string> v;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            v.push_back(s);
        }

        auto check = [&v](int start, int num) {
            int count{0};
            for (int j = start; j < v.size(); ++j) {
                count += v[j].size();
                if (count > num) {
                    break;
                }
                if (count == num) {
                    return make_pair(true, j + 1);
                }
            }
            return make_pair(false, start + 1);
        };
        int s = 0;
        while (true) {
            auto r1 = check(s, 5);
            if (r1.first) {
                auto r2 = check(r1.second, 7);
                if (r2.first) {
                    auto r3 = check(r2.second, 5);
                    if (r3.first) {
                        auto r4 = check(r3.second, 7);
                        if (r4.first) {
                            auto r5 = check(r4.second, 7);
                            if (r5.first) {
                                cout << (s + 1) << endl;
                                break;
                            }
                        }
                    }
                }
            }
            ++s;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	while(cin>>n,n){
		int a[40]={0},j=0,i=0,c,k=0;
		for(;j<n;j++){
			cin>>s;
			a[i++]=s.size();
		}
		for(j=0;j<35;j++){
			int b[4]={0};
			c=0;
		for(i=j;i<40;i++){
			c+=a[i];
			if(c==5)b[0]++;
			else if(b[0]&&c==12)b[1]++;
			else if(b[1]&&c==17)b[2]++;
			else if(b[2]&&c==24)b[3]++;
			else if(b[3]&&c==31){
				k=j;
				break;
			}
			if(!b[0]&&c>5)break;
		}if(k)break;
	    }
	    
		cout<<k+1<<endl;
	}
}

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

vector<string> a(40);

int main() {
  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<40;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){
                q=1+make(q,7);
                end=1;
              }
            }
          }
        }
      }
      if(end==1) break;
    }
    printf("%d\n",k+1);
    scanf ("%d",&n);
  }
}


int make(int k,int p){
  int l=0;
  int r=0;
  l=a[k].size();
  if(l==p){
    return k;
  }
  else{
    if(l<p){
      r=make(k+1,p-l);
      return r;
    }
    return -1;
  }
}

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



bool check(vector<int>& v, int i){

	  vector<int> x = {5,7,5,7,7};
	  int id=0;
	  for(int j=i; j<v.size(); j++){

			x[id] -= v[j];
			if( x[id] == 0 ){
				  id++;
				  if(id == 5) return true;
			}
			else if( x[id] < 0 ){
				  return false;
			}
	  }
	  return false;


}


int main(){
	  while(1){
			int n; cin >> n;
			if(!n) break;

			vector<int> v(n);
			for(int i=0; i<n; i++){
				  string in; cin >> in;
				  v[i] = in.size();
			}
			for(int i=0; i<n; i++){
				  if( check(v,i) ){
						cout << i+1 << endl;
						break;
				  }
			}
			
	  }
}