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>
using namespace std;

int main(){
  int n,a,b,c,d,e,j;
  string w[40];
  while(true){
    cin >> n;
    if(n == 0) break;

    for(int i = 0; i < n; i++){
      scanf("%d",&w[i]);
    }
    //cout << "n="<<n << endl;
    for(int i = 0; i < n - 4; i++){
      //start w[i] 5 7 5 7 7
      //cout << i << "=i" <<endl;
      a = 5;
      b = 7;
      c = 5;
      d = 7;
      e = 7;

      int j=i;
      bool flag = true;
      while(flag ){//5

        if(a - w[j].size() == 0){j++; break;}
        else if(j >= n){flag = false;}
        else if(a - w[j].size() > 0){a-=w[j].size(); j++;}
        else {flag = false;}
      }
      //cout << j << endl;
      while(flag){//7

        if(b - w[j].size() == 0){j++; break;}
        else if(j >= n ){flag = false;}
        else if(b - w[j].size() > 0){b-=w[j].size(); j++;}
        else {flag = false;}
      }
      //cout << j << endl;
      while(flag){//5

        if(c - w[j].size() == 0){j++; break;}
        else if(j >= n){flag = false;}
        else if(c - w[j].size() > 0){c-=w[j].size(); j++;}
        else {flag = false;}
      }
      //cout << j << endl;
      while(flag){//7

        if(d - w[j].size() == 0){j++; break;}
        else if(j >= n){flag = false;}
        else if(d - w[j].size() > 0){d-=w[j].size(); j++;}
        else {flag = false;}

      }
      //cout <<  j << endl;
      while(flag){//7

        if(e - w[j].size() == 0){  j++; break;}
        else if(j >= n){flag = false;}
        else if(e - w[j].size() > 0){  e -= w[j].size(); j++;}
        else {flag = false;}
      }
      if(flag){
        cout << i+1 << endl;
        break;
      }
    }
  }

  return 0;

}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

bool solve(int pos, vi v) {
    int res = 5;
    while(res>0) {
        res -= v[pos++];
        if(res<0) return false;
    }
    res = 7;
    while(res>0) {
        res -= v[pos++];
        if(res<0) return false;
    }
    res = 5;
    while(res>0) {
        res -= v[pos++];
        if(res<0) return false;
    }
    res = 7;
    while(res>0) {
        res -= v[pos++];
        if(res<0) return false;
    }
    res = 7;
    while(res>0) {
        res -= v[pos++];
        if(res<0) return false;
    }
    return true;
}

int main()
{
    int n;
    while(cin>>n, n) {
        vi v;
        rep(i,n) {
            string s;
            cin >> s;
            v.push_back(s.size());
        }
        rep(i,n) {
            if(solve(i,v)) {
                P(i+1);
                break;
            }
        }
    }
    return 0;
}

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

int main() {
	int n;

	while (cin >> n,n	)
	{

		vector<string> w;
		for (int i = 0;i < n;++i) {
			string tmp;
			cin >> tmp;
			w.push_back(tmp);
		}

		int flag = 0;
		int len = 0;
		int output = 100000000;
		for (int i = 0;i < n;++i) {
			flag = 0;
			len = 0;
			for (int j = i; j< n;++j) {
				len += w[j].size();
				if (flag == 0 || flag == 2) {
					if (len == 5) {
						len = 0;
						flag++;
					}
					else if (len > 5) {
						break;
					}
				}
				else {
					if (len == 7) {
						len = 0;
						flag++;
					}
					else if (len > 7) {
						break;
					}
				}
			}

			if (flag >= 5) {
				output = i + 1;
				break;
			}
		}

		cout << output << endl;
	}


}