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;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = 99999999;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int ls[] = {5,7,5,7,7};
    while(1){
        int n,w[40];
        cin >> n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            string s;
            cin >> s;
            w[i] = s.size();
        }
        for(int i=0;i<n;i++){
            int k=0,sum=0;
            for(int j=i;j<n;j++){
                if(sum < ls[k])sum += w[j];
                if(sum>ls[k])break;
                if(sum == ls[k]){
                    k++;
                    sum = 0;
                }
                if(k==5)break;
            }
            if(k==5){
                cout << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int n,w[10000];
string str,kari;
int main(){

  cin >> n;
  while( n != 0){
    fill_n(w,10000,0);
    w[0] = 1;

    for(int i = 0;i < n;i++){
      cin >> kari;
      if(i != 0) w[str.size()] = i+1;
      str += kari;
    }
    
    for(int i = 0;i <= str.size()-31;i++){
      if(w[i]!=0&&w[i+5]!=0&&w[i+12]!=0&&w[i+17]!=0&&w[i+24]!=0){
	if(i+31 == str.size() || w[i+31] != 0){
	  cout << w[i] << endl;
	  break;
	}
      }
    }
    cin >> n;
  }

  return (0);
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n;
	int a[] = { 5,7,5,7,7 };
	while (cin >> n, n)
	{
		vs v(n);
		REP(i, n) cin >> v[i];
		REP(i, n)
		{
			int p = 0, tmp = 0;
			bool f = true;
			FOR(j, i, n)
			{
				if (p == 5) break;
				tmp += v[j].size();
				if (tmp == a[p])
				{
					tmp = 0; p++;
				}
				else if (tmp > a[p])
				{
					f = false;
					break;
				}
			}
			if (f)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n;
        cin>>n;
        if(!n) return 0;
        vector<string> w(n);
        rep(i,0,n) cin>>w[i];
        rep(i,0,n){
            int j=i;
            int res=0;
            while(j<n&&res<5){
                res+=w[j].length();
                j++;
            }
            if(res!=5) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            res=0;
            while(j<n&&res<5){
                res+=w[j].length();
                j++;
            }
            if(res!=5) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            cout <<i+1<<"\n";
            break;
        }
    }
}

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

int main(){
  int n;
  while(std::cin >> n, n){
    int length[n];
    string s;
    for (int i = 0; i < n; i++) {
      std::cin >> s;
      length[i] = s.length();
    }
    vector<int> correct = {5, 7, 5, 7, 7};
    for (int i = 0; i < n; i++) {
      int tmp = 0, pos = 0;
      for (int j = i; j < n; j++) {
        tmp += length[j];
        if(tmp == correct[pos])pos++, tmp = 0;
        if(pos == correct.size()){
          std::cout << i + 1 << std::endl;
          i = j = 1e9;
        }
      }
    }
  }
  return 0;
}