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<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#define N (1000000000+7)
typedef long long ll;
using namespace std;

int main(void){
    int n;
    cin>>n;
    int b[5]={5,12,17,24,31};
    while(n!=0){
        string s;
        vector<int>a(n),sum(n+1);
        for(int i=0;i<n;i++){
            cin>>s;
            a[i]=s.length();
        }
        sum[0]=0;
        int num=0;
        for(int i=1;i<=n;i++){
            sum[i]=sum[i-1]+a[i-1];
        }
        for(int i=1;i<n;i++){
            num=0;
            for(int j=i;j<=n;j++){
                if(sum[j]==b[num]){
                    num++;
                    //cout<<sum[j]<<endl;
                }
                if(num==5)break;
            }
            if(num==5){
                cout<<i<<endl;
                break;
            }
            //cout<<"ks"<<endl;
            for(int k=1;k<=n;k++)sum[k]-=a[i-1];
        }
        cin>>n;
    }
    return 0;
}

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

int solve(const std::vector<int>& ls) {
	int cs[] = { 5, 12, 17, 24, 31 };
	for (int i = 0; i < ls.size(); i++) {
		int c = 0;
		int l = 0;
		for (int j = i; j < ls.size(); j++) {
			l += ls.at(j);
			if (cs[c] == l) {
				c++;

				if (c >= 5) {
					return i+1;
				}
			}
			else if (cs[c] < l) {
				break;
			}
		}
	}
	return -1;
}

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

		std::vector<int>ws;
		ws.resize(n);

		for (int i = 0; i < n; i++) {
			std::string s;
			std::cin >> s;
			ws.at(i) = s.size();
		}

		std::cout << solve(ws) << std::endl;


	}
}

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

using namespace std;

int check(vector<int> tanka){
	int roule[] = {5,7,5,7,7};
	int index = 0, i = 0, t = 0;
	int sum = 0;
	while(i < 5){
		do{
			sum += tanka[index+t];
			t++;
		}while(sum < roule[i]);
		if(sum > roule[i]){
			index++;
			i = 0;
			t = 0;
		}else{
			i++;
		}
		sum = 0;
	}
	return index+1;
}

int main(){
	vector<int> tanka;
	vector<int> res;
	int n;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			string tmp;
			cin >> tmp;
			tanka.push_back(tmp.size());
		}
		if(n > 0)
			res.push_back(check(tanka));
		tanka.clear();
		tanka.shrink_to_fit();
	}while(n > 0);

	for(auto num : res){
		cout << num << endl;
	}
	
	return 0;
}

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

int main(){
  int step,flag=0,n,l,x;
  while(1){
    cin >> n;
    if(n==0){break;}
    string w[n];
    for(int i=0;i<n;i++){
      cin >> w[i];
    }
    for(int i=0;i<n;i++){
      l=0;
      step=1;
      flag=0;
      x=i;
      while(1){
        if(flag==1){break;}
        l+=w[x].length();
        switch(step){
          case 1:
          if(l>5){flag=1;}
          else if(l==5){step++;}
          break;
          case 2:
          if(l>12){flag=1;}
          else if(l==12){step++;}
          break;
          case 3:
          if(l>17){flag=1;}
          else if(l==17){step++;}
          break;
          case 4:
          if(l>22){flag=1;}
          else if(l==22){step++;}
          break;
          case 5:
          if(l>29){flag=1;}
          else if(l==29){flag=2;}
          break;
        }
        if(flag==2){break;}
        x++;
      }
      if(flag=2){x=i+1;break;}
    }
    if(flag=2){cout << x << endl;}
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;



int main(){
	
int n;
while(1){
	cin>>n;
	if(!n)break;
	int p[50]={};;
	for(int i=0;i<n;i++){
		string y;
		cin>>y;
		p[i]=y.size();
	}
	
	for(int i=0;i<n;i++){
		bool a=0,b=0,c=0,d=0,e=0;
		int r=0;
		for(int j=i;j<n;j++){
			r+=p[j];
			if(!a&&r==5)a++;
			if(!a&&r>5)break;
			if(r==12)b++;
			if(!b&&r>12)break;
			if(r==17)c++;
			if(!c&&r>17)break;
			if(r==24)d++;
			if(!d&&r>24)break;
			if(r==31)e++;
			if(!e&&r>31)break;
			if(a&&b&&c&&d&&e){
				cout<<i+1<<endl;
				break;
			}
		}
		if(a&&b&&c&&d&&e){
				
				break;
			}
	}

}

	return 0;
}