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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int a[5] = {5,7,5,7,7};

int main(){

  int n;
  while(true){
    cin >> n;
    if(n == 0) break;

    vector<int> v;
    REP(i,n){
      string s;
      cin >> s;
      v.pb(s.length());
    }

    for(int i = 0; i < n - 4; ++i){
      int sum, j = i;
      bool tanka = true;
      for(int idx = 0; idx < 5; ++idx){
        sum = a[idx];
        while(true){
          if(sum == v[j]){
            sum = 0;
            j++;
            break;
          }else if(sum > v[j]){
            sum -= v[j];
            j++;
          }else{
            tanka = false;
            break;
          }
        }
        if(!tanka){
          break;
        }
      }
      if(tanka){
        cout << i+1 << endl;
        break;
      }

    }
  }
  return 0;
}

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

int main()
{
	int n;
	string tmp;
	while (cin >> n, n) {
		vector<string> v;
		v.reserve(n);
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}
		int del = 0;
		int flag = 0;
		while (flag != 5) {
			flag = 0;
			int length = 0;
			for (int i = del;i < v.size();i++) {
				length += v[i].size();
				if (length == 5 || length == 12 || length == 17 || length == 24 || length == 31)
					flag++;
			}
			del++;
		}
		cout << del << endl;
	}
	return 0;
}

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

int main() {
	while (true) {
		int n;
		cin >> n;

		if (n == 0)
			break;

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

			len[i] = w.size();
		}

		for (int i = 0;i < n;i++) {
			bool flg = false;
			int sta = 0;
			int sum = 0;

			for (int j = i;j < n;j++) {
				sum += len[j];

				//区切りなら
				if (sum == 5 || sum == 12 || sum == 17 || sum == 24 || sum == 31) {
					sta++;
				}

				if (sta == 5) {
					flg = true;
					break;
				}
				else if (sum >= 31) {
					break;
				}
			}
			if (flg) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

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

    for(int i = 0;i < n;i++){
      cin >> kari;
      if(i != 0) w[str.size()] = i+1;
      str += kari;
    }
    
    w[str.size()]=n+1;
    
    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&&w[i+31]!=0){
	cout << w[i] << endl;
	break;
      }
    }
    cin >> n;
  }
  return (0);
}

C++: #include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);i++)

int main()
{
  int n;
  while(1){
    cin >> n;
    int w[n];
    if(n == 0) break;
    REP(i,n){
      string s;
      cin >> s;
      w[i]= s.size();
    }
    int c, x;
    REP(i,n){
      x = 0;
      for(int j = i; j < n && x < 5; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 5) continue;
      for(int j = c; j < n && x < 12; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 12) continue;
      for(int j = c; j < n && x < 17; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 17) continue;
      for(int j = c; j < n && x < 24; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 24) continue;
      for(int j = c; j < n && x < 31; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 31) continue;
      cout << i+1 << endl;
      break;
    }
  }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>ns(N);
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			ns[i] = st.size();
		}
		vector<int>ls(5);
		ls[0] = 5;
		ls[1] = 7;
		ls[2] = 5;
		ls[3] = 7;
		ls[4] = 7;
		for (int i = 0; i < N; ++i) {
			int now = 0;
			int num = 0;
			bool ok = false;
			for (int j = i; j < N; ++j) {
				num += ns[j];
				if (num > ls[now]) {
					ok = false;
					break;
				}
				else if (num == ls[now]) {
					now++;
					if (now == 5) {
						ok = true;
						break;
					}
					else {
						num = 0;
					}
				}
			}
			if (ok) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}