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<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int i,n;
    string s;
    int haiku[]={5,7,5,7,7};
    int sum;
    vector<int> ans;
    while(1){
        haiku[0]=5;
        haiku[1]=7;
        haiku[2]=5;
        haiku[3]=7;
        haiku[4]=7;
        cin>>n;
        if(n==0)break;
        vector<int> v(n,0);
        rep(i,n){
            cin>>s;
            v[i]=s.length();
        }
        int phase=0;
        bool ch=false;
        // cout<<"-------------------------------"<<endl;
        rep(i,n-4){
            phase=0;
            int j=0;
            while(1){
                // cout<<j<<" "<<phase<<" "<<v[i+j]<<" "<<haiku[phase]<<endl;
                haiku[phase]-=v[i+j];
                if(haiku[phase]==0)phase++;
                else if(haiku[phase]<0)break;
                if(phase>=5){
                    ch=true;
                    break;
                }
                j++;
            }
            
            if(ch){
                ans.push_back(i+1);
                break;
            }
            haiku[0]=5;
            haiku[1]=7;
            haiku[2]=5;
            haiku[3]=7;
            haiku[4]=7;
        }
        
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
//////////////////////////////////////////////////////
return 0;}

C++: #include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<string> s(n);
            vector<int> A(n);
            REP(i, n) cin >> s[i];
            REP(i, n) A[i] = s[i].size();
            int ans;
            bool ok = false;
            REP(i, n + 1){
                int a = 0;
                bool tanka =  false;
                int now = 0; 
                FOR(j, i, A.size()){
                    a += A[j];
                    if(a > 7) break;
                    if((now == 0 or now == 2) and a == 5){
                        now++;
                        a = 0;
                    }
                    if((now == 1 or now == 3) and a == 7){
                        now++;
                        a = 0;
                    }
                    if(now == 4 and a == 7){
                        ok = true;
                        ans = i + 1;
                        break;
                    }
                }
                if(ok) break;
            }
            cout << ans << endl;
        }
    }
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
#include<limits>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;
typedef unsigned long long ull;
typedef long long ll;

int n;
vector<string> w;
int mozi[5]={5,7,5,7,7};

int main() {
  while(cin >> n && n){
    w.resize(n);
    R(i,0,n){
      cin >> w[i];
    }

    int out = 0;
    R(i,0,n){
      int sum=0,ku=0;
      R(j,i,n){
        sum += w[j].size();
        if(sum == mozi[ku]){
          sum=0;
          ku++;
          if(ku==5){
            out=i+1;
            goto A;
          }
        }else if(sum > mozi[ku]){
          break;
        }
      }
    }
    A: ;
    cout << out << endl;
    w.clear();
  }
  return 0;
}

C++: #include<bits/stdc++.h>
main(){for(char s[50],i,j,p,q;p=atoi(gets(s)),p;printf("%d\n",i)){for(i=0;i<p;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++]);}}