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>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	while(1){
		cin1(n);
		if (n == 0) break;
		
		vs str(n);
		for_(i,0,n) {
			cin1(str[i]);
		}
		
		int ans = 0;
		for_(i,0,n) {
			int idx = 0;
			ans = i;	
			vi check = {5,7,5,7,7};
			for_(j,i,n) {
					if(check[idx] <= 0) {
						idx++;
					}
					if (idx == 6){
						break;
					}
					check[idx] -= str[j].size();
					
			}
			int sum = 0;
			for_(k,0,5) {
				sum += check[k];
			}
			if (sum == 0){
				break;
			}

		}
		cout(ans+1);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;
    while (true)
    {
        cin >> n;
        if (n == 0)
            break;
        std::vector<string> v(n);
        for (int i = 0; i < n; i++)
        {
            cin >> v[i];
        }
        int tanku[5] = {5, 7, 5, 7, 7};
        for (int i = 0; i < n - 1; i++)
        {
            int cnt = 0, idx = 0;
            for (int j = 0; i + j < n; j++)
            {
                cnt += v[i + j].length();
                //cout<<cnt<<" "<<idx<<endl;
                if (cnt < tanku[idx])
                    continue;
                else if (cnt == tanku[idx])
                {
                    idx++;
                    cnt = 0;
                }
                else
                {
                    break;
                }
            }
            if (idx == 5)
            {
                cout << i + 1 << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int N;
int wc[40];
int nec[5] = {5,7,5,7,7};

int main() {
  while (cin >> N, N) {
    REP(i, N) {
      string str;
      cin >> str;
      wc[i] = str.size();
    }
    
    int nec[5] = {5, 7, 5, 7, 7};
    bool en = false;
    REP(i, N) {
      if (en) break;
      int cur = 0, cnt = 0;
      FOR(j, i, N) {
        cnt += wc[j];
        if (cnt == nec[cur]) {
          cur++;
          cnt = 0;
          if (cur == 5) {
            cout << i + 1 << endl;
            en = true;
            break;
          }
        }
      }
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int len[] = {5,7,5,7,7};
int main(){
  int n;
  while(cin >> n , n){
    string str[n+1];
    for(int i=0;i<n;i++){
      cin >> str[i];
    }
    for(int i=0;i<n;i++){
      int sum = 0;
      int idx = 0;
      bool flag = false;
      for(int j=i;j<n;j++){
	sum += str[j].size();
	if(len[idx] == sum){
	  sum = 0;
	  idx++;
	} else if(len[idx] < sum) break;
	if(idx == 5){
	  flag = true;
	  break;
	}
      }
      if(flag){
	cout << i+1 << endl;
	break;
      }
    }
  }
}

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

using namespace std;

using i64 = long long int;
using ui64 = unsigned long long int;

////////

int main(){
    int n;
    const vector<int> tanku = {5,7,5,7,7};
    while(cin >> n,n){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            string s;
            cin >> s;
            a[i] = s.length();
        }
        int res = -1;
        for(int i=0;i<n;i++){
            int id = 0;
            vector<int> p = tanku;
            for(int j=i;j<n;j++){
                // cerr << i << " " << j << " " << a[j] << " " << p[id] << endl;
                if(a[j] < p[id])p[id] -= a[j];
                else if(a[j] == p[id])id++;
                else if(a[j] > p[id]){
                    // cerr << i << ": " <<  id << endl;
                    break;
                }
                if(id==p.size()){
                    res = i + 1;
                    goto output;
                }
            }
        }
output:
        cout << res << endl;
    }
}