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 pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

void solve(ll n) {
        vector<ll> v(n);
    vector<ll> w{5,7,5,7,7};
    rep(i, n) {
        string s; cin >> s;
        v[i] = s.size();
    }
    rep(i, n) {
        ll j = i;
        vector<ll> need = w;
        try {
            each(c, need) {
                while (c) {
                    if (j >= n) throw 1;
                    c -= v[j++];
                }
            }
            cout << i+1 << endl;
            return;
        }
        catch (int err) {
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) solve(n);
}

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

int main(){
  int n;
  int d_words[5]={5,7,5,7,7};
  while(cin>>n && n!=0){
    int* n_words=new int[n];
    for(int i=0;i<n;i++){
      string str;
      cin>>str;
      n_words[i]=str.size();
    }
    int start=0;
    int success=0;
    while(!success){
      int t_words=0;
      int tmp=start;
      int tmp2=0;
      while(1){
        tmp2+=n_words[tmp];
        if(tmp2==d_words[t_words]){
          t_words++;
          if(t_words==5){
            success=start+1;
            break;
          }else if(tmp2>d_words[t_words]){
            break;
          }
        }
        tmp++;
      }
      start++;
    }
    cout<<success<<endl;
  }
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) {
            string str;
            cin >> str;
            i = str.size();
        }

        for (int i = 1; i < N; i++) {
            v[i] += v[i-1];
        }
        v.insert(v.begin(), 0);

        int idx = 0;
        int seq[] = {5, 12, 17, 24, 31};
        while (1) {
            bool flag = true;
            int idx_ = idx;
            for (int i = 0; flag && i < 5; i++) {
                while (idx_ < N && v[idx_] - v[idx] < seq[i]) {
                    idx_++;
                }
                if (v[idx_] - v[idx] != seq[i]) flag = false;
            }
            if (flag) break;
            idx++;
            if (N <= idx) {
                flag = false;
                break;
            }
        }

        cout << idx + 1 << endl;
    }

    return 0;
}

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

int N, len[41];
int p[6] = { 0, 5, 7, 5, 7, 7 };

bool check(int s) {
  // cout << s << endl;
  REP(i, 1, 5) {
    int d = 0;
    while(s <= N) {
      d += len[s++];
      // cout << "  " << s << " " << i << " " << d << endl;
      if(d > p[i]) return false;
      if(d == p[i]) break;
    }
    if(d < p[i]) return false;
  }
  return true;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 1, N) {
      string S; cin >> S;
      len[i] = S.length();
    }

    REP(i, 1, N) {
      if(!check(i)) continue;
      cout << i << endl;
      goto CONTINUE;
    }

CONTINUE: continue;
  }

  return 0;
}

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

int main(){
        string str;
        int i,j,sum,ans,n,x,flg;
        int a[40];

        while(1) {
                cin>>n;

                if(n==0) {
                        break;
                }

                for(i=0; i<n; i++) {
                        cin>>str;
                        a[i]=str.length();
                }

                for(i=0; i<n; i++) {
                        sum=0;
                        flg=1;
                        for(j=i; j<n; j++) {
                                sum=sum+a[j];
                                if(sum==5||sum==12||sum==17||sum==24||sum==31) {
                                        flg++;
                                }
                        }
                        if(flg==6) {
                                cout<<i+1<<endl;
                                break;
                        }
                }
        }
}