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 <cstdio>
#include <string>
#include <vector>

using namespace std;

int solve(void);
int getItr(const int pos, const int length, vector<string> &w);

int main(void) {

	//FILE* fpin = freopen("data.txt", "r", stdin);

	while (solve()) {}

	return 0;

}

int solve(void) {

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

	cin >> n;
	if (!n) { return 0; }

	vector<string> w(n);

	for (int i = 0; i < n; i++)
		cin >> w[i];

	for (int j = 0; j < n; j++) {
		int pos = -1 + j;
		for (int i = 0; i < 5; i++) {
			pos = getItr(pos, len[i], w);
			if (pos < 0) { break; }
			if (pos >= 0 && i == 4) {
				cout << j + 1 << endl;
				return 1;
			}
		}
	}

}

int getItr(const int pos, const int length, vector<string>& w)
{
	/*
		w???pos+1????????????????????????????????????
		?????????????????????????????????length????????£?????¨???,?????????????????????????????????????????????
		???????????????-1?????????
	*/
	int cnt = 0;
	for (int i = pos + 1; i < w.size(); i++) {
		cnt += w[i].length();
		if (cnt == length) { return i; }
	}
	return -1;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

signed main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin>>n,n){
        vector<int> v(n);
        REP(i,n){
            string s; cin>>s;
            v[i]=s.size();
        }

        REP(i,n){
            int pos=i;
            int A[]={5,7,5,7,7};
            REP(j,5){
                int cnt=0;
                while(pos<n && cnt<A[j]) cnt+=v[pos++];
                if(cnt!=A[j]) goto g;
            }
            cout<<i+1<<endl;
            break;
        g:;
        }
    }
}

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

vector<int> v;
int d[5] = {5 ,7, 5, 7, 7};

int main(){
while(1){//start	
	
	int n;
	cin >> n;
	if(n == 0) break;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		v.push_back((int)s.size());
	}
	
	//debug
	//for(int i = 0; i < n; i++) cout << v[i] << endl;
	
	int ans = 0;
	for(int i = 0; i < n - 1; i++){
		int len = 0;
		int tmp = 0;
		int next = 0;
		for(int j = i; j < n; j++){
			len += v[j];
			tmp += v[j];
			if(next == 4 and len == 31){
				ans = i + 1;
				goto end;
			}
			else if(d[next] == tmp){
				//cout << tmp << endl;
				tmp = 0;
				next++;
			}
		}
		//cout << endl;
	}
	
	end:
	cout << ans << endl;
	
	v.clear();
}//end
	return 0;
}

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

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

    string tmp;
    int w[n];
    for(int i = 0 ; i < n ; i++){
      cin >> tmp;
      w[i] = tmp.length();
    }

    int ans = -1;

    for(int i = 0 ; i < n - 4 ; i++){
      int  cur = i;
      bool istanku = true;

      int sum = 0;
      for(int j = 0 ; cur + j < n ; j++){
        sum += w[cur + j];
        if(sum == 5){
          cur = i + j + 1;
          break;
        }else if(sum > 5){
          istanku = false;
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 5){
            cur = cur + j + 1;
            break;
          }else if(sum > 5){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

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

    cout << ans << endl;

  }
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    vector<int> v;
    int checkPoint[] = {5, 7, 5, 7, 7};
    while(cin >> n && n){
        v.resize(n);
        for(auto&& i : v){
            string str;
            cin >> str;
            i = str.size();
        }
        for(int i = 0; i < n; i++){
            int cnt = 0, p = 0;
            for(int j = i; j < n; j++){
                cnt += v[j];
                if(checkPoint[p] < cnt){
                    break;
                }
                if(checkPoint[p] == cnt){
                    cnt = 0;
                    p++;
                    if(p == 5){
                        break;
                    }
                }
            }
            if(p == 5){
                cout << i + 1 << "\n";
                break;
            }
        }
    }
}