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 <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int N;
  while(1){
    cin>>N;
    if(N==0){
      break;
    }
    VE V;
    FOR(i,0,N){
      string S;
      cin>>S;
      V.PB((int)S.size());
    }
    FOR(i,0,N){
      int sum=0;
      int now=i;
      while(sum<5){
        sum+=V[now];
        now++;
      }
      if(sum!=5){
        continue;
      }
      while(sum<12){
        sum+=V[now];
        now++;
      }
      if(sum!=12){
        continue;
      }
      while(sum<17){
        sum+=V[now];
        now++;
      }
      if(sum!=17){
        continue;
      }
      while(sum<24){
        sum+=V[now];
        now++;
      }
      if(sum!=24){
        continue;
      }
      while(sum<31){
        sum+=V[now];
        now++;
      }
      if(sum==31){
        cout<<i+1<<endl;
        break;
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  while(1){ 
    cin>>n;
    if(n==0)break;
    string str;
    int len[45];
    int i,j;
    int ans;

    rep(i,n){
      cin>>str;
      len[i]=str.size();
    }
    rep(i,n){
      int tanku[5]={5,7,5,7,7};
      int now=0;
      for(j=i;j<n;j++){
	if(len[j]>tanku[now])break;
	if(len[j]==tanku[now])now++;
	else tanku[now]-=len[j];
	if(now==5) goto ANS;
      }
    }
  ANS:cout<<i+1<<endl;
  }

}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int a[5] = {5,7,5,7,7};
signed main() {
	int n;
	while (cin >> n && n) {
	    vector<int> v(n);
	    rep(i, n) {
	        string s; cin >> s;
	        v[i] = s.size();
	    }
	    rep(i, n) {
	        bool ok = true;
	        int idx = 0;
	        int sum = 0;
	        rep(j, 5) {
	            while (i + idx < n && sum < a[j]) {
	                sum += v[i + idx++];
	              }
	            if (sum > a[j]) {
	                ok = false;
	                break;
	            }
	            sum = 0;
	        }
	        if (ok) {
	            cout << i + 1 << endl;
	            break;
	        }
	    }
    }
}

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

int main(){
  while(1){
    int N;
    cin >> N ;
    vector<int> a;
    if(N==0){
      break;
    }
    for(int i=0;i<N;i++){
      string str;
      cin >> str;
      a.push_back(str.size());
    }
    for(int i=0;i<N;i++){
      int tanka=0;
      int sum=0;
      for(int j=i;j<N;j++){
        sum+=a[j];
        if(sum==5&&(tanka==0||tanka==2)||sum==7&&(tanka==1||tanka==3||tanka==4)){
          tanka++;
          sum=0;
        }
      }
      if(tanka==5){
        cout << i+1 << endl;
        break;
      }
    }
  }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<int> a(n);
    for(int i=0; i<n; i++){
      string s;
      cin >> s;
      a[i] = s.size();
    }

    for(int i=0; i<n; i++){
      int t[5] = {5,7,5,7,7};
      int p = 0;
      int tmp = 0;
      for(int j=i; j<n; j++){
        tmp += a[j];
        if( tmp == t[p] ){
          p++;
          tmp = 0;
        }else if( tmp > t[p] ){
          tmp = 0;
          break;
        }
      }
      if( p == 5 ){
        cout << i + 1 << endl;
        break;
      }
      // cerr << " " << p << endl;
    }

  }

  return 0;
}


// EOF

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

int d[] = {5,7,5,7,7};
signed
main(){
	int n;
	while(cin >> n && n!=0)
	{
			vector<int> w(n);
			for(int i=0;i<n;i++)
			{
					string s;
					cin >> s;
					w[i] = (int)s.size();
			}

			for(int i=0;i<n;i++)
			{
					int a[5] = {};
					int key = 0;
					bool flag = true;
					for(int j=i;j<n;j++)
					{
							if(key == 5){
									break;
							}
							a[key] += w[j];
							if(a[key] == d[key]){
									key++;
							}else if(a[key] < d[key]){

							}else if(a[key] > d[key]){
									flag = false;
									break;
							}
					}

					if(flag){
							cout << i+1 << endl;
							break;
					}
			}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[]={5,7,5,7,7},n,i,j,c,k;
  while(cin>>n,n){
    string s[n];
    for(i=0;i<n;i++)cin>>s[i];
    for(i=0;i<n;i++){
      c=k=0;
      for(j=i;j<n;j++){
        c+=s[j].size();
        if(c==a[k]){
          c=0;
          if(++k==5)goto L;
        }
      }
    }
    L: if(k==5)cout<<i+1<<endl;
  }
}