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 <vector>
using namespace std;

int main() {
    int n;
    while(cin >> n, n) {
        int cnt[5] = {5, 7, 5, 7, 7};
        vector<string> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }
        int res = 0;
        for(int i=0; i<n; ++i) {
            int c = 0, len = 0;
            bool ok = false;
            for(int j=i; j<n; ++j) {
                len += v[j].size();
                if(len == cnt[c]) {
                    if(c == 4) {
                        ok = true;
                        res = i+1;
                        break;
                    }
                    c++;
                    len = 0;
                } else if(len > cnt[c]) {
                    break;
                }
            }
            if(ok) {
                cout << res << endl;
                break;
            }
        }
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main()
{
    while(true){
        int n;
        cin >> n;
 
        if(n==0)
            break;
 
        string w[40];
        int len[40];
        for(int i=0; i<n; i++){
            cin >> w[i];
            len[i] = w[i].size();
        }
 
        for(int i=0; i<n; i++){
            bool flg = false;
            int sta = 0;
            int sum = 0;
 
            for(int j=i; j<n; j++){
                sum += len[j];
 
                if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
                    sta++;
                }
 
                if(sta==5){
                    flg = true;
                    break;
                }
                else if(sum>=31){
                    break;
                }
            }
 
            if(flg){
                cout << i+1 << endl;
                break;
            }
        }
    }
 
    return 0;
}

C++: #include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int arr[7368792];
signed main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0)break;
        vector<string> s(n);
        rep(i,n)cin >> s[i];
        for(int i = 0;i <= n-5;i++){
            int num[5] = {0};
            int stage = 0;
            int flag = 0;
            for(int j = i;j < n;j++){
                if(stage == 0){
                    num[stage] += s[j].size();
                    if(num[stage] == 5)stage++;
                    else if(num[stage] > 5)break;
                }else if(stage == 1){
                    num[stage] += s[j].size();
                    if(num[stage] == 7)stage++;
                    else if(num[stage] > 7)break;
                }else if(stage == 2){
                    num[stage] += s[j].size();
                    if(num[stage] == 5)stage++;
                    else if(num[stage] > 5)break;
                }else if(stage == 3){
                    num[stage] += s[j].size();
                    if(num[stage] == 7)stage++;
                    else if(num[stage] > 7)break;
                }else if(stage == 4){
                    num[stage] += s[j].size();
                    if(num[stage] == 7){
                        cout << i+1 << endl;
                        flag = 1;
                        break;
                    }
                    else if(num[stage] > 7)break;
                }
            }
            if(flag)break;
        }
    }
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc133.contest.atcoder.jp/tasks/abc133_b

C++: #include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)
int n;
int mem;
int count1;
int count2;
string s[40];
bool check;

void test(int k, int l){
  count1 = 0;
  for(int j=0; j+k<n; j++){
    count1 += s[k+j].length();
    if(count1 > l)return;
    if(count1==l){
      count2++;
      if(l==5&&count2==1){
        mem = k;
      }
      if(l==7){
        if(count2==5){
          check = true;
          return;
        }
      }
      switch(count2){
        case 1: return test(k+j+1,7);
        case 2: return test(k+j+1,5);
        case 3: return test(k+j+1,7);
        case 4: return test(k+j+1,7);
      }
    }
  }
}

int main(){
  while(cin>>n&&n){
    check = false;
    REP(i,n){
      cin >> s[i];
    }
    REP(i,n){
      count1 = 0;
      count2 = 0;
      test(i,5);
      if(check==true){
        cout << mem+1 << endl;
        break;
      }
    }
  }
  return 0;
}