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<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n;
	while(cin>>n){
		if (n == 0)break;
		vector<string> v;
		string s; int out=0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(s);
		}
		while (true) {
			int x = out;
			bool f = true;
			int cnt = 0;
			while (x<n&&cnt+(int)v[x].size() <= 5) {
				cnt+=v[x].size();
				x++;
			}
			if (cnt != 5) {
				f = false;
			}
			cnt = 0;
			while (x<n&&cnt + (int)v[x].size() <= 7) {
				cnt += v[x].size();
				x++;
			}
			if (cnt != 7) {
				f = false;
			}
			cnt = 0;
			while (x<n&&cnt + (int)v[x].size() <= 5) {
				cnt += v[x].size();
				x++;
			}
			if (cnt != 5) {
				f = false;
			}
			cnt = 0;
			while (x<n&&cnt + (int)v[x].size()<=7){
				cnt += v[x].size();
				x++;
			}
			if (cnt != 7) {
				f = false;
			}
			cnt = 0;
			while (x<n&&cnt + (int)v[x].size() <= 7) {
				cnt += v[x].size();
				x++;
			}
			if (cnt != 7) {
				f = false;
			}
			if (f)break;
			out++;
		}
		cout << out+1 << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  while (1) {
    int chars=0;int tanku[5]={5,7,5,7,7};int block=0;//block???tanku??????????????´??°???v?????£??????leng???tanku??¨??????????????£?????´???
    int leng=0,istart=1;
    scanf("%d",&chars);
    if(chars==0){
      return 0;
    }
    std::vector<string> v(chars);
    for (size_t i = 0; i < chars; i++) {
      std::cin >> v[i];
    }

    //???????????§????????¨??\???
    //??????????????????

    for (size_t i = 0; block<=4; i++) {
      leng+=v[i].size();
      if (leng>tanku[block]) {
        block=0;leng=0;
        i=istart-1;istart++;
      }else if(leng==tanku[block]){
        block++;leng=0;
      }
    }
    printf("%d\n",istart);
  }
  return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> len(n);
        for(int i = 0 ; i < n ; i++){
            string w;
            cin >> w;
            len[i] = w.size();
        }

        int ans = -1;
        int tanku[] = {5, 7, 5, 7, 7};
        for(int i = 0 ; i < n ; i++){
            int cnt = 0, now = 0;
            bool ok = true;
            for(int j = i ; j < n ; j++){
                cnt += len[j];
                if(cnt == tanku[now]){
                    now++;
                    cnt = 0;
                }else if(cnt > tanku[now]){
                    ok = false;
                }
                if(now >= 5){
                    break;
                }
            }
            if(ok){
                ans = i + 1;
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    int w[5] = {5, 7, 5, 7, 7};
    while (cin >> n && n){
        VI a(n);
        REP(i,n) {
            string s;
            cin >> s;
            a[i] = s.length();
        }
        REP(s,n){
            int x = 0, i = s, j = 0, f = 1;
            while (f){
                x += a[i];
                i++;
                if (x > w[j]) f = 0;
                if (x == w[j]){
                    x = 0;
                    j++;
                }
                if (j == 5) break;
            }
            if (f) cout << s+1 << endl;
        }
    }

    return 0;
}