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>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        vector<int> W;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            W.push_back(s.size());
        }
        // cout<<n<<endl;
        int C[5]={5,7,5,7,7};
        for(int i=0;i<n;i++){
            bool done = false;
            for(int j=i,c=0,cnt=0;j<n;j++){
                cnt+=W[j];
                // cout<<cnt<<endl;
                if(cnt<C[c]) continue;
                else if(cnt==C[c]){
                    c++;
                    cnt=0;
                    if(c==5){
                        cout<<i+1<<endl;
                        done = true;
                        break;
                    }
                }else{
                    break;
                }
            }
            if(done) break;
        }
    }
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int num[5]={5,7,5,7,7},n,cnt=0,step,size,ie,f=0;
  string s[40];
  cin >> n;
  while(n!=0){
    cnt=0;
    step=0;
    for(int i=0;i<n;i++){
      cin >> s[i];
    }
    for(int i=0;i<n;i++){
      f=0;
      ie=0;
      for(int j=0;j<5;j++){
        size=0;
        while(num[j]>size){
        size += s[i+ie].length();
          ie++;
        }
        if(num[j]!=size){
          f=1;
          break;
        }
      }
    if(f==0){
      cout << i+1<<endl;
      break;
    }
  }
  cin >> n;
}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
using namespace std;
typedef long long int ll;

int n;
int p[]={5,12,17,24,31};

void solve(){
	vector<int> a(n+1);
	for(int i=0;i<n;i++){
		string s; cin >> s;
		a[i+1]=a[i]+(int)s.size();
	}
	for(int i=0;i<n;i++){
		int j=0;
		for(int k=i+1;k<=n;k++){
			if(a[k]==a[i]+p[j]){
				j++;
				if(j==5)break;
			}
		}
		if(j==5){
			printf("%d\n",i+1 );
			return;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n==0)break;
		solve();
	}
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> w(n);
		for (int i = 0; i < n; ++i) {
			string s; cin >> s;
			w[i] = s.size();
		}
		int ok[] = { 5,7,5,7,7 };
		for (int i = 0; i < n; ++i) {
			int sum = 0, now = 0, j = 0;
			while (now < 5 && sum < ok[now]) {
				sum += w[i + j++];
				if (sum == ok[now]) now++, sum = 0;
			}
			if (now == 5) {
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<math.h>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());
  int n;
  string inp;
  int set[5]={5,12,17,24,31};
  while(1){
    cin >> n;
    if(n==0)return 0;

    //int list[n];
    int shori[n];
    int size;
    int ans=0;
    //  int num=0;
    for(int i=0;i<n;i++){
      cin >> inp;
      size=inp.size();
      shori[i]=0;
      //cout << list[i] << endl;
      for(int j=0;j<=i;j++){
	if(shori[j]==-1)continue;
        for(int l=0;l<5;l++){
	  if(shori[j]<set[l]){
	    if(size<=set[l]-shori[j]){
	      shori[j]+=size;
	      break;
	    }else{
	      shori[j]=-1;
	    }
	  }
	}
	if(shori[j]==set[4]){
	  ans++;
	  shori[j]=-1;
	}
      }
   
    }
    cout << ans <<endl;
  }
      
}

C++: #include<cstdio>
using namespace std;

int n;
int s[40];

int size(char *w) {
  int counter = 0;
  while (w[counter] != 0) counter++;
  return counter;
}

bool ok(int f, int s) {
  if (s <= 5) return true;
  if (f >= 5 && s <= 12) return true;
  if (f >= 12 && s <= 17) return true;
  if (f >= 17 && s <= 24) return true;
  if (f >= 24 && s <= 31) return true;
  return false;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      char w[15];
      scanf("%s", w);
      s[i] = size(w);
    }
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
        if (!ok(sum, sum + s[j])) break;
        sum += s[j];
        if (sum == 30) break;
      }
      if (sum == 31) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
}

C++: #include<iostream>
#define f(X) for(c=0;c<X;c+=v[p++]);if(c-X)continue;
using namespace std;
main(){
    for(int n;cin>>n,n;){
        int v[50],s,p,c;
        for(s=0;s<n;s++){string t;cin>>t;v[s]=t.size();}
        for(s=p=0;;p=++s){f(5);f(7);f(5);f(7);f(7);cout<<s+1<<endl;break;}
    }
}