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 rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N;
    int tanku[] = {5,7,5,7,7};
    vector<int> ans;
    while(true){
        cin >> N;
        if(N == 0) break;
        vector<int> work(N);
        rep(i, N){
            string temp; cin >> temp;
            work[i] = temp.length();
        }
        rep(i, N){
            int idx = i;
            int acc = 0;
            int phase = 0;
            while(phase < 5 && acc < tanku[phase]){
                acc += work[idx];
                if(acc == tanku[phase]){
                    acc = 0;
                    phase++;
                }
                idx++;
            }
            if(phase == 5){
                ans.push_back(i+1);
                break;
            }
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int flag[5]={5,7,5,7,7};
  while(cin >> n,n){
    string str;
    vector<int> cnt;
    rep(i,n){
      cin >> str;
      int tmp = str.size();
      cnt.push_back(tmp);
    }
    bool finish = false;
    rep(i,n){
      //cout << "#" << endl;
      int stage = 0;
      int sum = cnt[i];
      if(sum > flag[0]) continue;
      else if(sum == flag[0]) {
        stage++;
        sum = 0;
      }
      for(int j=i+1; j<n; j++){
        //cout << stage  << " " << sum << endl;
        sum += cnt[j];
        if(sum > flag[stage]) break;
        else if(sum == flag[stage]){
          stage++;
          sum = 0;
        }
        if(stage == 5) {
          cout << i+1 << endl;
          finish  = true;
          break;
        }
      }
      if(finish == true) break;
    }
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int make(int w,int p);

vector<string> a(50);

int main() {
  int n;
  scanf ("%d",&n);
  while(n){

    for(int t=0;t<n;t++){
      //scanf ("%s",a[t]);
      cin >> a[t];
    }
    /*for(int t=n;t<50;t++){
      //scanf ("%s",a[t]);
      a[t]="";
    }*/
    int end=0;
    int k=0;
    for(k=0;k<n;k++){
      int q=k;
      if(make(q,5)>=1){
        q=1+make(q,5);
        if(make(q,7)>=1){
          q=1+make(q,7);
          if(make(q,5)>=1){
            q=1+make(q,5);
            if(make(q,7)>=1){
              q=1+make(q,7);
              if(make(q,7)>=1){
                end=1;
                //printf("qwqw\n");
              }
            }
          }
        }
      }
      if(end==1) break;
    }
    printf("%d\n",k+1);
    scanf ("%d",&n);
  }
}


int make(int w,int p){
  int l=a[w].size();
  if(l==p){
    return w;
  }
  else{
    if(l<p){
      //printf("%d\n",r);
      return make(w+1,p-l);
    }
    else{
      return -1;
    }
  }
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
bool check(int x, vector<string>v) {
	int table[] = { 5,7,5,7,7 };
	int idx = 0, tmp = 0;
	rep(i, x, v.size()) {
		tmp += v[i].size();
		if (tmp == table[idx]) {
			idx++;
			tmp = 0;
		}
		else if (tmp > table[idx]) {
			return false;
		}
		if (idx == 5) {
			return true;
		}
	}
	return false;
}
signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v; vector<string>s; v.push_back(0);
		rep(i, 0, n) {
			string t;
			cin >> t;
			s.push_back(t);
			v.push_back(t.size());
		}
		rep(i, 1, n + 1) {
			v[i] += v[i - 1];
		}
		int ans;
		for (ans = 0; ans < n + 1; ans++) {
			rep(j, ans, n + 1) {
				int x = v[j] - v[ans];
				if (x > 31)continue;
				else if (x == 31 && check(ans, s))goto there;
			}
		}

	there:; cout << ans + 1 << endl;
		dumpc(v);

	}
	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<vector>
#include<string>

using namespace std;

int check(vector<int> tanka){
	int roule[] = {5,7,5,7,7};
	int index = 0, i = 0, t = 0;
	int sum = 0;
	while(i < 5){
		do{
			sum += tanka[index+t];
			t++;
		}while(sum < roule[i]);
		if(sum > roule[i]){
			index++;
			i = 0;
			t = 0;
		}else{
			i++;
		}
		sum = 0;
	}
	return index+1;
}

int main(){
	vector<int> tanka;
	vector<int> res;
	int n;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			string tmp;
			cin >> tmp;
			tanka.push_back(tmp.size());
		}
		if(n > 0)
			res.push_back(check(tanka));
		tanka.clear();
		tanka.shrink_to_fit();
	}while(n > 0);

cout << "test" << endl;
	for(auto num : res){
		cout << num << endl;
	}
	
	return 0;
}