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;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vi a(n);
        REP(i, n) {
            string s; cin >> s;
            a[i] = s.size();
        }

        vi nums = { 5, 7, 5, 7, 7};
        REP(i, n) {
            int cnt = 0;
            int idx = 0;
            bool valid = false;
            FOR(j, i, n) {
                cnt += a[j];
                if (cnt > nums[idx]) break;
                if (cnt == nums[idx]) {
                    cnt = 0;
                    if (++idx == 5) {
                        valid = true;
                        break;
                    };
                }
            }
            if (valid) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    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){
      printf("\n");
      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 ",istart);
  }
  return 0;
}

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

using namespace std;

int main(void) {
	int n;
	int tan[5] = {5,7,5,7,7};
	cin >> n;
	while (n != 0) {
		vector<string> str(n);
		for (int i = 0; i < n; ++i) {
			cin >> str[i];
		}
		bool find = false;
		bool over = false;
		int ind = 0;
		int ln = 0;
		int ret;
		for (int i = 0; !find && i < n; ++i) {
			over = false;
			ind = 0;
			ln = 0;
			for (int j = i; !over && j < n; ++j) {
				if (ln + str[j].length() == tan[ind]) {
					if (ind == 4) {
						find = true;
						ret = i+1;
					}
					else {
						++ind;
						ln = 0;
					}
				}
				else if (ln + str[j].length() < tan[ind]) {
					ln += str[j].length();
				}
				else {
					over = true;
				}
			}
		}
		cout << ret << endl;
		cin >> n;
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(){
	while(1){
		LOOP:
		int n;
		scanf("%d",&n);
		if(!n) break;
		char w[40][11];
		int c[40];
		for(int i=0;i<n;i++){
			scanf("%s",w[i]);
			c[i]=strlen(w[i]);
		}
		int f[]={5,7,5,7,7};
		int k;
		int tmp;
		for(int i=0;i<n;i++){
			k=0;
			tmp=0;
			for(int j=i;j<n;j++){
				if(f[k]<tmp+c[j])
					break;
				tmp+=c[j];
				if(tmp==f[k]){
					k++;
					tmp=0;
				}
				if(k==5){
					printf("%d\n",i+1);
					goto LOOP;
				}
			}
		}
	}
	return 0;
}