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

using namespace std;

int main() {
  int n;
  const int tank[] = {5, 7, 5, 7, 7};
  while (cin >> n && n) {
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
      string ww;
      cin >> ww;
      w[i] = ww.length();
    }
    int ans = -1;

    for (int i = 0; i < n - 5; i++) {  //??????????????°?????????????????????
      int tmp = 0;
      int cnt = 0;
      for (int j = i; j < n; j++) {
        tmp += w[j];
        //cerr << tmp << " ";
        if (tmp < tank[cnt]) {
          //?¶???????????????§?????????????¬???????????????????
        } else if (tmp == tank[cnt]) {
          //????????????????????§?¬???????????????????
          tmp = 0;
          cnt++;
          if (cnt == 5) {
            // 57577????????£???
            ans = i + 1;
            goto FIN;
          }

        } else {
          //??¢???????????§??±???
          break;
        }
      }
      //cerr << endl;
    }

  FIN:
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	vector<string> v;
	int n,t=0,count=0,tt;
	
	for (;;) {
		cin >> n;
		if (n == 0)break;
		v.resize(n);
		for (int i = 0; i < n; i++) cin >> v[i];
		
		for (int j = 0; j < n; j++) {
			for (int i = j; i < n; i++) {
				//cout << v[i].size() << endl;
				if (count == 0) {
					t += v[i].size();
					if (t == 5)count++;
					else if (t > 5) {
						count = 0;
						t = 0;
						break;
						
					}

				}
				else if (count == 1) {
					t += v[i].size();
					if (t == 12) count++;
					else if (t > 12) {
						count = 0;
						t = 0;
						break;
						
					}

				}
				else if (count == 2) {
					t += v[i].size();
					if (t == 17) count++;
					else if (t > 17) {
						t = 0;
						count = 0;
						break;
					}

				}
				else if (count == 3) {
					t += v[i].size();
					if (t == 24) count++;
					else if (t > 24) {
						t = 0;
						count = 0;
						break;
						
					}

				}
				else if (count == 4) {
					t += v[i].size();
					if (t == 31) {
						count++;
						break;
					}
					else if (t > 31) {
						t = 0;
						count = 0;
						break;
					}

					tt = j + 1;


				}
			}
			if (count == 5) {
				cout << tt << endl;
				t = 0;
				count = 0;
				break;
			}
		}
		


	}
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using pii = pair<int,int>;

template<typename T> ostream& operator<< (ostream& os,const vector<T>& vec){ os << "{"; for(T v:vec) os << v << ","; os << "}"; }
template<typename T> ostream& operator<< (ostream& os,const set<T>& st){ os << "{"; for(T v:st) os << v << ","; os << "}"; }
template<typename T,typename U> ostream& operator<< (ostream& os,const pair<T,U>& p){ os << "{" << p.first << "," << p.second << "}"; return os; }

int N;
string w[40];

int main(){
    while (true) {
        cin >> N;
        if (N == 0) break;
        for (int j = 0; j < N; ++j) {
            cin >> w[j];
        }

        int len[5] = {5, 7, 5, 7, 7};

        for (int j = 0; j < N; ++j) {
            int state = 0,acc = 0;
            for (int k = j; k < N && state < 5; ++k) {
                acc += (int)w[k].size();
                if (acc > len[state]) {
                    break;
                } else if (acc == len[state]) {
                    acc = 0; ++state;
                }
            }

            if (state == 5) {
                cout << (j+1) << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include <cassert>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define lINF LLONG_MAX/3
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repl(i,s,n) for(int i=(s);i<=(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define MP make_pair
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<":"<<#y<<"="<<x<<":"<<y<<endl


void solve(int n){
    vector<string> w(n);
    rep(i,n) cin >> w[i];

    rep(i,n) repl(j,i+1,n-1) repl(k,j+1,n-1) repl(l,k+1,n-1) repl(m,l+1,n-1){
        string s;
        for(int x=i;x<j;x++) s+=w[x];
        if(s.size()!=5) continue;
        s.clear();
        for(int x=j;x<k;x++) s+=w[x];
        if(s.size()!=7) continue;
        s.clear();
        for(int x=k;x<l;x++) s+=w[x];
        if(s.size()!=5) continue;
        s.clear();
        for(int x=l;x<m;x++) s+=w[x];
        if(s.size()!=7) continue;
        s.clear();
        for(int x=m;x<n;x++){
            s += w[x];
            if(s.size()==7){
                cout << i+1 << endl;
                return;
            }
        }
    }
}

int main(){
    int n;
    while(cin>>n && n){
        solve(n);
    }
}