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 <bits/stdc++.h>
using namespace std;

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

int main(){
    int n;
    while(scanf("%d",&n), n != 0){
        string w[40];
        for(int i=0;i<n;++i)cin >> w[i];
        for(int i=0;i<n;++i){
            int k=0, cnt=0, j=i;
            while(k < 5 && j < n){
                cnt += w[j].size();
                if(cnt > tanku[k])break;
                if(cnt == tanku[k]){
                    ++k;
                    cnt = 0;
                }
                ++j;
            }
            if(k == 5){
                printf("%d\n",i+1);
                break;
            }
        }
    }

    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int make(int w,int p);

vector<string> a(50);

int main() {
  int n;
  scanf ("%d",&n);
  while(n){

    for(int t=0;t<n;t++){
      //scanf ("%s",a[t]);
      cin >> a[t];
    }
    for(int t=n;t<50;t++){
      //scanf ("%s",a[t]);
      a[t]="";
    }
    int end=0;
    int k=0;
    for(k=0;k<n;k++){
      int q=k;
      if(make(q,5)>=1){
        q=1+make(q,5);
        if(make(q,7)>=1){
          q=1+make(q,7);
          if(make(q,5)>=1){
            q=1+make(q,5);
            if(make(q,7)>=1){
              q=1+make(q,7);
              if(make(q,7)>=1){
                end=1;
                //printf("qwqw\n");
              }
            }
          }
        }
      }
      if(end==1) break;
    }
    printf("%d\n",k+1);
    scanf ("%d",&n);
  }
}


int make(int w,int p){
  int l=a[w].size();
  int r=0;
  if(l==p){
    return w;
  }
  else{
    if(l<p){
      r=make(w+1,p-l);
      //printf("%d\n",r);
      return r;
    }
    else{
      return -1;
    }
  }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str[40];

void solve(){
	rep(i,n) cin >> str[i];
	rep(i,n){
		int cnt[5] = {5,7,5,7,7};
		for(int j = i; j < n; j++){
			rep(k,5){
				if(cnt[k] != 0){
					cnt[k] -= str[j].size();
					break;
				}
			}
		}
		bool ok = true;
		rep(j,5) if(cnt[j] != 0) ok = false;
		if(ok) cout << i+1 << endl;
	}
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

C++: #include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


bool read(const vector<int>& w, const int siz, int& now)
{
	const int n = w.size();
	int cnt = 0;
	while (now < n && cnt<siz) {
		cnt += w[now];
		now++;
	}
	return (cnt == siz);
}

//計算
void calc(vector<int> w)
{
	int n = w.size();
	REP(start, n) {
		int now = start;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 7, now))continue;
		//cerr << "answer     ";
		cout << start + 1 << endl;
		return;
	}
	//cout << "ERROR" << endl;
}



//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true) {
		int n;
		vector<int> w;
		string tmp;
		cin >> n;
		if (n == 0)break;
		REP(i, n) {
			cin >> tmp;
			w.push_back(tmp.size());
		}
		calc(w);
	}
	//debug();
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define rep(i,n) for(int i = 0; i < n ;++i)
#define all(v) v.begin(),v.end()

int main() {
  int n;
  while(cin >> n) {
    if (n == 0) {
      break;
    }
  vector<string> w(n);
  vector<int> d(n);
  for (int i =0; i < n; i++) {
    cin >> w[i];
    d[i] = w[i].size();
  }
  for (int i = 0; i < n; i++) {
    bool h = true;
    int st[5] = {0};
    int lm[5] = {5, 7, 5, 7, 7};
    int a = 0;
    for (int j = i; j < n; j++) {
      for (int k = a; k < 5; k++) {
        if (st[k] < lm[k]) {
          st[k] += d[j];
          break;
        } else if (st[k] > lm[k]) {
          h = false;
          break;
        }
        a++;
      }
      if (!h) {
        break;
      } else if (a == 5) {
        break;
      }
    }
    if (h) {
      cout << i+1 << endl;
      break;
    }
  }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define  INF 1100000000
#define	 MOD 1000000007
using namespace std;

int main(){
	int N;
	while(cin >> N, N != 0){
		string w;
		int size[1000];
		for(int i=0;i<N;i++){
			cin >> w;
			size[i+1] = w.size();
		}
		
		for(int i=1;i<=N;i++){
			int count=0, j=i;
			while(count < 5){
				count += size[j];
				j++;
			}
			if(count != 5){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			count = 0;
			while(count < 5){
				count += size[j];
				j++;
			}
			if(count != 5){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			cout << i << endl;
			break;
		}
	}
	return 0;
	
}