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 <functional>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int k[5] = {5,7,5,7,7};
int n; 
string str[50];

bool dfs(int s, int c, int sum) {
    if (sum + str[s].length() == k[c]) {
        if (c == 4) return true;
        else return dfs(s+1, c+1, 0);
    }
    else if (sum + str[s].length() > k[c]) return false;
    else return dfs(s+1, c, sum + str[s].length());
}

int main(void){
    while (1) {
        cin >> n;
        if (!n) break;
        for (int i = 0; i < n; i++) cin >> str[i];
        for (int i = 0; i < n; i++) {
            int x = dfs(i, 0, 0);
            if (x == false) continue;
            cout << i+1 << endl;
            break;
        }
    }
    
    return 0;
}

C++: s[50],i,j,p,q;
main(n){for(;n=atoi(gets(s)),n;printf("%d\n",i)){
for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=j++>5?0:j-2&&j-4?8:6;q>1;q-=s[p++]);
}}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

string str[41];
int k;
int n;

bool check(int p, int c)
{
	int cnt =0;
	for(int i=p;i<n;i++){
		cnt += str[i].length();
		k++;
		if(cnt == c) return true;
		else if(cnt > c)return false;
	}
	return false;
}

int main(){
	while(cin>>n, n){
		rep(i,n) cin >> str[i];
		rep(i,n){
			k = i;
			if(check(k,5) && check(k,7) && check(k,5) && check(k,7) && check(k,7)) {
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v; vector<string>s; v.push_back(0);
		rep(i, 0, n) {
			string t;
			cin >> t;
			s.push_back(t);
			v.push_back(t.size());
		}
		rep(i, 1, n + 1) {
			v[i] += v[i - 1];
		}
		int ans;
		for (ans = 0; ans < n + 1; ans++) {
			rep(j, ans, n + 1) {
				int x = v[j] - v[ans];
				if (x > 31)continue;
				else if (x == 31)goto there;
			}
		}

	there:; cout << ans + 1 << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ls;
    for(int i = 0; i < n; i++) {
      string s;
      cin >> s;
      ls.push_back(s.length());
    }
    for(int i = 0; i < n; i++) {
      int j = i, k = 0;
      int tls[] = {5,7,5,7,7};
      for(;;) {
        if(ls[j] <= tls[k]) {
          tls[k]-=ls[j];
          j++;
        } else {
          break;
        }
        if(tls[k] == 0) k++;
        if(k == 5) {
          cout << (i+1) << endl;
          i = n;
          break;
        }
      }
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int N;
int tanka[] = {5,7,5,7,7};

int f(){
	vector<int>a(N);
	string s;
	REP(i,N){
		cin>>s;
		a[i] = s.size();
	}
	int now = 0,tmp = 0;
	REP(i,N){
		now = i;
		tmp = 0;
		REP(j,5){
			while(tmp<tanka[j]){
				tmp += a[now];
				now++;
			}
			if(tmp>tanka[j])break;
			else if(j==4)return i+1;
			tmp = 0;
		}
	}
}

signed main(){
	vector<int>ans;
	while(cin>>N,N)ans.push_back(f());
	for(auto e:ans)cout<<e<<endl;
}

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

int main(void){
	int n,n_l[40],count=0,cap=0;
	char w[10];
	scanf("%d",&n);

	int i;
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%s",w);
			n_l[i]=strlen(w);
		}
		for(i=0;;i++){
			count=0;
			cap=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			count=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			break;
		}
		printf("%d\n",i+1);
		scanf("%d",&n);
	}
	return 0;
}