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


vector<string> goku;

int checkKu(int bgn, int chlen) {
	int len = 0;
	int i = 0;
	while (1) {
		len += goku[bgn+i].size();
		i+=1;
		if (len > chlen)return -1;
		else if (len == chlen)return i;
	}
}

bool solve(int start) {
	int Ku[5] = { 5,7,5,7,7 }, k = start;
	for (int i = 0; i < 5; i++) {
		int j = checkKu(k, Ku[i]);
		//cout << j << endl;
		if (j > 0)k += j;
		else return false;
	}
	return true;
}

int main() {

	while (1) {
		int n;
		goku.clear();
		cin >> n;
		if (n == 0)break;
		//input
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			goku.push_back(str);
		}

		int s = 0;
		while (1) {
			if (solve(s))break;
			else s++;
		}
		cout << s + 1 << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){
  string s[100];
  int a[7]={5,7,5,7,7};
  rep(i,n){
    cin>>s[i];
  }
  rep(i,n){
    int p=0;
    int m=0;
    FOR(j,i,n){
      m += (int)s[j].length();
      if(m==a[p]){
        m=0;
        p++;
      }
    }
    if(p==5){
      cout<<i+1<<endl;
      break;
    }
  }
}



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

  return 0;
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> p(n);
    REP(i,n) cin >> p[i];
    REP(i,n){
      int tmp=0,count=0;
      FOR(j,i,n){
	tmp+=p[j].size();
	if(tmp==5||tmp==12||tmp==17||tmp==24||tmp==31) ++count;
	if(tmp>=31) break;
      }
      if(count==5){
	cout << i+1 << endl;
	break;
      }
    }
  }
}

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

vector<string> a(50);

void main(void){
  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;
    }
    k++;
    printf("%d\n",k);
    scanf ("%d",&n);
  }
}


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

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
int n;
int tanku[]={5,7,5,7,7};
while(1){
cin>>n;
if(n==0)break;
string a;
vector<int> w(n);
for(int i=0;i<n;i++){
	cin>>a;
	w[i]=a.size();
}
int plase;
for(int i=0;i<n;i++){
plase=i;
int sum=0;
int k=0;
bool flag=false;
for(int j=i;j<n;j++){
sum+=w[j];
if(sum>tanku[k])break;
if(sum==tanku[k]){
	k++;
	sum=0;
}
if(k==5){
	flag=true;
	break;
}
}
if(flag){
	cout<<i+1<<endl;
	break;
}
}
}	
return 0;
}

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

using VI = vector<long>;

long TMP[5] = {5, 7, 5, 7, 7};

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n) {
      VI ps;
      for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ps.push_back(s.size());
      }
      for (int first = 0; first < n; first++) {
        int diff = 0;
        bool legal = true;
        for (int k = 0; k < 5; k++) {
          int acc = 0;
          while (acc < TMP[k]) {
            acc += ps[first + diff];
            diff++;
          }
          if (acc > TMP[k]) {
            legal = false;
            break;
          }
        }
        if (legal) {
          cout << first+1 << endl;
          break;
        }
      }
    } else {
      return 0;
    }
  }
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int tanku[5] = { 5,7,5,7,7 };

	while (true) {
		int n;
		cin >> n;

		if (n == 0) {
			break;
		}

		vector<string> strings(n);

		for (int i = 0; i < n; i++) {
			cin >> strings[i];
		}

		int ans;

		for (int i = 0; i < n; i++) {
			bool flag = true;
			int cur = 0;
			int size = 0;

			for (int j = i; j < n; j++) {
				size += strings[j].size();

				if (size > tanku[cur]) {
					flag = false;
					break;
				}

				if (size == tanku[cur]) {
					cur++;
					size = 0;
					if (cur == 5) {
						break;
					}
				}
			}

			if (flag == true) {
				ans = i + 1;
				break;
			}
		}

		cout << ans << endl;
	}

	return 0;
}