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 <vector>
#include <string>
using namespace std;

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

    vector<string> w(n);
    for(int i=0; i<n; i++)
      cin >> w[i];
         
    int tanku[5] = {5, 7, 5, 7, 7};
    bool judge = false;
    for(int i=0; i<n; i++){
      int place = i;
      for(int j=0; j<5; j++){
	int sum = 0;
	while(place <= n-1){
	  sum += w[place].size();
	  place++;
	  if(j == 4 && sum == tanku[j]){
	    cout << i+1 << endl;
	    judge = true;
	    break;
	  }
	  if(sum >= tanku[j])
	    break;
	}
	if(sum > tanku[j])
	  break;
      }
      if(judge == true)
	break;
    }
  }
  
  return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    while(true){
        int n; cin >> n;
        if(n == 0)break;
        vector<string> s(n);
        int key[5] ={ 5, 7,5,7,7};
        for(int i = 0; i < n; i++)cin >> s[i];
        for(int i = 0; i < n; i++){
            if(s[i].size() > key[0])continue;
            int c = 0,k = i;
            for(int j = 0; j < 5; j++){
                c = 0;
                while(c < key[j] && k < n){
                    c += s[k].size();
                    k++;
                }
                if(c != key[j]){
                    c = -1;
                    break;
                }
            }
            if(c != -1){
                cout << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
void format(int a[]){
  for(int i=0;i<5;i++){
    if(i==0||i==2)
      a[i]=5;
    else
      a[i]=7;
  }
}
int main(){
  int n;
  while(cin>>n,n!=0){
    string word[n];
    for(int i=0;i<n;i++)
      cin>>word[i];
    int cnt[n];
    format(cnt);
    for(int j=0;j<n;j++){
      int flag=0;
      format(cnt);
      int pointer=0;
      for(int i=j;i<n;i++){
	cnt[pointer]-=word[i].size();
	if(cnt[pointer]<0)
	  break;
	else if(cnt[pointer]==0&&pointer==4){
	  cout<<j+1<<endl;flag=1;break;
	}else if(cnt[pointer]==0)
	  pointer++;
      }
      if(flag==1)
	break;
    }
  }
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

const int len[6] = {5,7,5,7,7,-1};

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		vector< string > s(n);
		for_(i,0,n) cin >> s[i];
		
		for_(i,0,n) {
			int p = 0, sum = 0;
			for_(j,i,n) {
				sum += s[j].size();
				if (sum > len[p]) break;
				if (sum == len[p]) {
					sum = 0;
					++p;
				}
			}
			
			if (p == 5) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

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 <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	while(1){
		int n; cin >> n;
		if(!n) return 0;
		vector<int>z;
		for(int i=0;i<n;i++){
			string a; cin >> a; z.push_back(a.size());
		}
		for(int i=0;i<n;i++){
			int cur = 0; int cnt = 0;
			for(int j=i;j<z.size();j++){
				cur += z[j];
				if(cur < 5) continue;
				if(cur > 7) goto fail;
				if(cur == 5 && (cnt==0||cnt==2)){
					cnt++; cur = 0;
				}
				else if(cur == 7 && (cnt==1||cnt==3||cnt==4)){
					cnt++; cur = 0;
				}
				if(cnt == 5){
					printf("%d\n",i+1); goto nxt;
				}
			}
		  fail:;
		}
	  nxt:;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

bool check_tanku(std::vector<std::string> v, int ind) {
	int piv = 0;
	int n = v.size();
	int l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}

	return true;
}

int main(void) {
	int n;
	int limit = 31;
	cin >> n;

	while ( n != 0 ) {
		std::vector<std::string> tan(n);
		std::vector<int> len(n,0);
		bool find = false;
		for (int i = 0; i < n; i++) {
			cin >> tan[i];
		}

		for (int i = 0; i < n; i++) {
			for (int j = i; j < n && len[i] < limit; j++) {
				len[i] += tan[j].length();
			}
		}

		int temp;
		for (int i = 0; i < n && !(find); i++) {
			if (len[i] == limit) {
				if (check_tanku(tan,i)) {
					cout << i+1 << endl;
					find = true;
				}
			}
		}

		cin >> n;
	}

	return 0;
}