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 <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

int main() {
	while (cin >> n, n) {
		string s;
		vector<int> v;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(s.length());
		}
		int a[] = { 5,7,5,7,7 };
		int b[] = {0,0,0,0,0};
		int sf = 0;
		int now = 0;
		int i = 0;
		while (1) {
			if (b[now] < a[now]) {
				b[now] += v[i];
				i++;
				continue;
			}
			else if (b[now] == a[now]) {
				if (now == 4)break;
				else {
					now++;
				}
			}
			else {
				sf++;
				now = 0;
				i = sf;
				for (int j = 0; j < 5; j++)b[j] = 0;
			}
		}
		cout << sf + 1 << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int n, a[SIZE];
int tanka[5] = {5, 7, 5, 7, 7};

bool dfs(int now = 0, int p = 0){
  int sum = 0;

  if(p == 5) return true;
  
  for(int i=now;i<n;i++){
    sum += a[i];
    if(tanka[p] == sum && dfs(i+1, p+1)) return true;
    if(tanka[p] < sum) return false;
  }

  return false;
}

bool solve(){

  scanf("%d", &n);

  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    char s[11];
    scanf("%s", s);
    a[i] = strlen(s);
  }

  for(int i=0;i<n;i++){
    if(dfs(i)){
      printf("%d\n", i+1);
      return true;
    }
  }

  return true;
}


int main(){
  while(solve());
  
  return 0;
}

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

int main(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n = -1;
    int rule[] = {5, 7, 5, 7, 7};
    for(;;){
        cin >> n;
        if(n == 0) break;
        int len[n];
        string str;
        for(int i = 0; i<n; i++){
                cin >> str;
                len[i] = str.length();
        }
        for(int start = 0; start < n; start++){
            int j = 0;
            int count = 0;
            for(int i = start; i<n; i++){
                count += len[i];
                if(count == rule[j]){
                    j++;
                    count = 0;
                    if(j == 5){
                        cout << start+1 << "\n";
                        start = 114514; // go to next set
                    }
                }else if(count > rule[j]){
                    i = 114514; // go to next start
                }
            }
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(!n)break;
		string w[n];
		rep(i,n)cin>>w[i];
		int a[]={5,7,5,7,7};
		int c,s;
		rep(i,n){
			c=s=0;
			REP(j,i,n){
				s+=w[j].length();
				if(s>a[c])break;
				if(s==a[c]){
					s=0;
					c++;
				}
				if(c==5){
					cout<<i+1<<endl;
					goto END;
				}
			}
		}
		END:;
	}
	return 0;
}