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 <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main(void)
{
  int tannka[5] = {5, 7, 5, 7, 7};
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int w;
    vector<string> v;
    v.resize(n);
    
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    
    //?????????1~5??????  //??\???????????°
    pair<int,int> count = make_pair(0,0);
    for (int i = 0; i < n; i++) {
      string str = v[i];
      //?????????1?????????5????????\?????????
      if (tannka[count.first] >= str.size()) {
	w = i;
	//5????????????
	if (tannka[count.first] == str.size()) {
	  count.first++;
	  count.second = 0;
	}
	//5??????????????????
	else {
	  count.second += str.size();
	}
	
	//?????????1?????????2?????????5??????
	for (int j = i+1; j < n; j++) {
	  str = v[j];
	  if (tannka[count.first] - count.second > str.size()) {
	    count.second += str.size();
	  } else if (tannka[count.first] - count.second == str.size()) {
	    count.first++;
	    count.second = 0;
	  } else {
	    count = make_pair(0,0);
	    break;
	  }
	  //???????????´??£???
	  if (count.first == 5) {
	    cout << w+1 << endl;
	    break;
	  }
	}

	if (count.first == 5)
	  break;
	
      }
      //?????????1?????????5????????§??????
      else { }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int calc(int p, int c, const vector<string> &s){
	int tmp = 0;
	while(tmp < c) tmp += s[p++].size();
	if(tmp == c) return p;
	return -1;
}

int main(){
	while(1){
		int n = in.nextInt();
		if(n == 0) break;
		vector<string> s(n);
		rep(i, n) s[i] = in.next();
		vi d(n + 1);
		rep(i, n) d[i + 1] = d[i] + s[i].size();
		int a[] = {5, 7, 5, 7, 7};
		rep(i, n){
			int p = i;
			for(int j = 0; j < 5; j++){
				p = calc(p, a[j], s);
				if(p < 0) break;
			}
			if(p >= 0){
				cout<<i + 1<<endl;
				break;
			}
		}
	}
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int n;
    while (cin >> n, n) {
        vector<string> w(n);
        REP (i, n) cin >> w[i];
        vector<int> v = {5, 7, 5, 7, 7};
        REP (i, n) {
            int sum = 0, idx = 0;
            FOR (j, i, n) {
                if (sum + w[j].size() > v[idx]) {
                    idx = -1;
                    break;
                }
                sum += w[j].size();
                if (sum == v[idx]) {
                    sum = 0;
                    idx++;
                }
                if (idx == v.size()) break;
            }
            if (idx < 0) continue;
            cout << i + 1 << endl;
            break;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin >> n and n){
		vector<int> v;
		for(int i = 0 ; i < n ; i++){
			string s;
			cin >> s;
			v.push_back(s.size());
		}
		for(int i = 0 ; i < n ; i++){
			int j = i;
			int s = 0;
			int f = 1;
			while( j < n and s < 5 ) s += v[j++];
			
			if( s != 5 ) f = 0;
			s = 0;
			while( j < n and s <7 ) s += v[j++];
			if( s != 7 ) f = 0;
			s = 0;
			while( j < n and s < 5 ) s += v[j++];
			if( s != 5 ) f = 0;
			s = 0;
			while( j < n and s < 7 ) s += v[j++];
			if( s != 7 ) f = 0;
			s = 0;
			
			while( j < n and s < 7) s += v[j++];
			if( s != 7 ) f = 0;
			
			if( f ){
				cout << i+1 << endl;
				break;
			}
		}
	}
}