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 <bits/stdc++.h>

using namespace std;

bool judge(int* a)
{
    int x[5] = {5, 7, 5, 7, 7};
    int i = 0;
    while(true)
    {
        if(i==5) return true;
        x[i] -= *a++;
        if(x[i]<0) return false;
        if(x[i]==0) i++;
    }
}

int main()
{
    int n;
    while(cin >> n, n)
    {
        int a[n];
        for(int i=0; i<n; i++)
        {
            string s;
            cin >> s;
            a[i] = s.size();
        }
        for(int i=0; i<n; i++)
        {
            if(judge(a+i))
            {
                cout << i+1 << endl;
                break;
            }
        }
    }
}

C++: #include<vector>
#include<iostream>
#include<string>
using namespace std;
int a0 = 5;
int a1 = 7;
int a2 = 5;
int a3 = 7;
int a4 = 7;
int main() {
	int n;
	while (cin >> n, n != 0) {
		vector<int>v(n);
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			int x = str.size();
			v[i] = x;
		}
		for (int i = 0; i < n; i++) {
			int k = i;
			int ans = i;
			int a = a0;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				

			}
			a = a1;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a2;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a3;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					break;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
			a = a4;
			while (a > 0) {
				a -= v[k];
				k++;
				if (k == n) {
					goto OUT;
				}
				if (a == 0) {
					cout << ans + 1 << endl;
				}
				else if (a < 0) {
					goto OUT;
				}
				
			}
		OUT:
			;
		}

	}
	return 0;
}


// 5 12 17 24 31

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

bool solve(int a){
	int i = a;
	int res = 0;
	while(i < v.size()){
		res += v[i].size();
		i++;
		if(res == 5){
			while(i < v.size()){
				res += v[i].size();
				i++;
				if(res == 12){
					while(i < v.size()){
						res += v[i].size();
						i++;
						if(res == 17){
							while(i < v.size()){
								res += v[i].size();
								i++;
								if(res == 24){
									while(i < v.size()){
										res += v[i].size();
										i++;
										if(res == 31)return true;
										else if(res > 31)return false;
									}
								}
								else if(res > 24)return false;
							}
						}
						else if(res > 17)return false;
					}
				}
				else if(res > 12)return false;
			}
		}
		else if(res > 5)return false;
	}
	return false;
}

int main(){
	int n;
	string s;
	while(cin >> n,n){
		v.clear();
		for(int i = 0;i < n;i++){
			cin >> s;
			v.push_back(s);
		}
		for(int i = 0;i < n;i++){
			if(solve(i)){
				cout << i+1 <<endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int a[5] = {5, 7, 5, 7, 7};

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        vi v(n);
        rep(i, n) {
            string s;
            cin >> s;
            v[i] = s.size();
        }

        auto check = [&](int first){
            int t = 0;
            int j = 0;
            rep2(i, first, n) {
                if (t < a[j]) {
                    t += v[i];
                }
                if (t > a[j]) {
                    return false;
                }
                if (t == a[j]) {
                    j++;
                    t = 0;
                }
                if (j == 5) {
                    return true;
                }
            }
        };

        rep(i, n) {
            if (check(i)) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}