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<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PI;
using namespace std;
#define MAX  999999
int main(){
    int n;
    while(cin >> n,n){
         vi v(10000,0);
        rep(i, n){string s; cin >> s; v[i] = (int)s.length();}
        int ans = 0;
        rep(i, n){
            int temp = 0; int array[] = {5,7,5,7,7}; int counter = 0;
            ans = i+1;
            for(int k = i;k<n;k++){
                temp+=v[k];
                if(temp == array[counter])
                {   temp = 0; counter++;
                    if(temp == 0 && counter == 5) goto L;
                }
            }
        }
    L:cout << ans << endl;
        ans = 0;
        
    }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main() {
	while (1) {
		int n, j, count, i, ans;
		const int rule[5] = {5, 7, 5, 7, 7};
		string w[41];
		queue<pair<int, int> > kouho;
		
		cin >> n;
		if (n == 0) break;
		REP(i, n) cin >> w[i];
		ans = 0;
		
		while(ans<n){
			j = 0;
			count = 0;
			i = ans;
			while (i < n) {
				count += w[i].length();
				//if (w[i].length() <= 5) kouho.push(make_pair(i,i));
				//debug(i);
				if (count == rule[j]) {
					//debug(count);
					//debug(j);
					if (j >= 4) {
						cout << ans+1 << endl;
						ans = n;
						break;
					}
					count = 0;
					j++;
					i++;
				} else if (count > rule[j]) {
					ans++;
					break;
				} else {
					i++;
				}
			}
		}
		//cout << "------------" << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	
	while (1) {
		bool check = false;
		int n;
		int now = 1;
		int count = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string> w(n + 1);
		vector<int>dp(n + 1);
		FOR(i, 1, n) {
			cin >> w[i];
			dp[i] = w[i].size();
		}
		FOR(i, 1, n) {
			bool flag = true;
			now = 1;
			count = 0;
			FOR(t, i, n) {
				count += dp[t];
				switch (now) {
				case 1:
					if (count > 5) {
						flag = false;
					}
					else if (count == 5) {
						now++;
						count = 0;
					}
					break;
				case 2:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				case 3:
					if (count > 5) {
						flag = false;
					}
					else if (count == 5) {
						now++;
						count = 0;
					}
					break;
				case 4:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				case 5:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				}
				if (flag == false) {
					break;
				}
				if (now == 6) {
					cout << i << endl;
					check = true;
					break;
				}
			}
			if (check == true) {
				break;
			}
		}
	}
}

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

int main() {
  int n;

  constexpr int check[] = {5, 7, 5, 7, 7};

LOOP:
  while (std::cin >> n, n != 0) {
    std::vector<std::string> v(n);

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


    for (int i = 0; i < n; ++i) {
      int cnt = 0, idx = 0;
      for (int j = i; j < n; ++j) {
        cnt += v[j].size();
        if (cnt == check[idx]) {
          cnt = 0;
          idx++;
        }
        if (idx == 5) {
          std::cout << i + 1 << std::endl;
          goto LOOP;
        }
      }
    }
  }
}

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

int solve(vector<int> &a) {
    int n = a.size();
    for (int i = 0; i < n; i++) {
        int cur = i;
        bool ok = true;
        for (int tgt: {5, 7, 5, 7, 7}) {
            int cnt = 0;
            while (cur < n && cnt + a[cur] <= tgt) cnt += a[cur++];
            if (cnt != tgt) { ok = false; break; }
        }
        if (ok) return i;
    }
    return -1;
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> len(n);
        for (int i = 0; i < n; i++) {
            string s; cin >> s;
            len[i] = s.size();
        }
        cout << solve(len) + 1 << endl;
    }
    return 0;
}