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<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


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

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n); if(!n)break;
    vector<string> s;
    s.resize(n); scn(n, s);

    bool fl = false;
    rep(i, n){
      int sum = 0, sp = 0;
      for(j = i;j < n;++j){
        sum += s[j].size();
        if(sum == f[sp]){
          sp++; sum = 0;
        }else if(sum > f[sp]){
          sum = 0; break;
        }
        if(sp >= 5){ fl = true; break; }
      }
      if(fl)break;
    }
    pri(i + 1);

//*/

//*/ break;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
int i,j,d[50],p,n,q,a[5]={5,7,5,7,7};
char s[15];
main(){
	for(n=1;n;){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s",s);
			d[i]=strlen(s);
		}
		for(i=0;i<n;i++){
			p=i;
			for(j=0;j<5;j++){
				q=a[j];
				while(q>0){
					q-=d[p];p++;
				}
				if(q)p=-1;
			}
			if(p>=0){
				printf("%d\n",i+1);
				break;
			}
		}
	}
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

int g[5]={5,7,5,7,7};
int main() {
    int n;
    while(true){
        cin>>n;
        if(n==0)break;

        vector<int> s;
        rep(i,n){
            string ss;
            cin>>ss;
            s.push_back((int)ss.size());
        }

        for(int i=0;i<n;i++){
            int st=i;int prew=0;
            int ind=0;
            while(st<n&&ind<5){
                prew+=s[st];
                st++;
                if(prew==g[ind]){
                    prew=0;ind++;
                }else if(prew>g[ind]){
                    break;
                }
            }
            if(ind==5){
                cout<<i+1<<endl;
                break;
            }


        }


    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  while (1) {
    int chars=0;int tanku[5]={5,7,5,7,7};int block=0;//block???tanku??????????????´??°???v?????£??????leng???tanku??¨??????????????£?????´???
    int leng=0,istart=1;
    scanf("%d",&chars);
    if(chars==0){
      printf("\n");
      return 0;
    }
    std::vector<string> v(chars);
    for (size_t i = 0; i < chars; i++) {
      std::cin >> v[i];
    }

    //???????????§????????¨??\???
    //??????????????????

    for (size_t i = 0; block<=4; i++) {
      leng+=v[i].size();
      if (leng>tanku[block]) {
        block=0;leng=0;
        i=istart-1;istart++;
      }else if(leng==tanku[block]){
        block++;leng=0;
      }
    }
    printf("%d\n",istart);
  }
  return 0;
}

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

int main(){
  int n;
  int d_words[5]={5,7,5,7,7};
  while(cin>>n && n!=0){
    int* n_words=new int[n];
    for(int i=0;i<n;i++){
      string str;
      cin>>str;
      n_words[i]=str.size();
    }
    int start=0;
    int success=0;
    while(!success){
      int t_words=0;
      int tmp=start;
      int tmp2=0;
      while(1){
        tmp2+=n_words[tmp];
        if(tmp2==d_words[t_words]){
          t_words++;
          if(t_words==5){
            success=start+1;
            break;
          }
}else if(tmp2>d_words[t_words]){
            break;
          }
        
        tmp++;
      }
      start++;
    }
    cout<<success<<endl;
  }
}