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;

int main(void){
  vector<int> tanku{5, 7, 5, 7, 7};
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    vector<string> w(n);
    for(int i = 0; i < n; i++){
      cin >> w[i];
    }
    int idx = 0;
    int len = 0;
    while(idx < (int)w.size()){
      bool istanku = true;
      int ans = idx;
      for(int i = 0; i < (int)tanku.size(); i++){
        while(1){
          len += w[idx].size();
          idx++;
          if(len > tanku[i]){
            len = 0;
            istanku = false;
            break;
          }
          if(len == tanku[i]){
            len = 0;
            break;
          }
        }
        if(istanku == false) break;
      }

      if(istanku){
        cout << 1+ans << endl;
        break;
      }else{
        idx = ans+1;
      }
    }

  }
  return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    while(cin >> n, n){
    int len[] = {5, 7, 5, 7, 7};
    string w[44];
    for(int i = 0; i < n; i++) cin >> w[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0, idx = 0;
        for(int j = i; j < n; j++){
        cnt += w[j].size();
        if(cnt == len[idx]){
            cnt = 0, idx++;
            if(idx == 5) break;
        }else if(cnt > len[idx]){ idx = -1; break;}
        }
        if(idx == 5){ ans = i; break;}
    }
    cout << ans+1 << endl;
    }
    return 0;
}

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

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

    int N;
    int len[5] = {5, 7, 5, 7, 7};
    while (cin >> N, N) {
        vector<int> w(N);
        for (int i = 0; i < N; i++) {
            string s; cin >> s;
            w[i] = s.size();
        }

        for (int i = 0; i < N; i++) {
            int pos = 0;
            bool flag = true;
            for (int j = 0; j < 5; j++) {
                int n = 0;
                while (i+pos < N && n < len[j]) {
                    n += w[i+pos];
                    pos++;
                }
                if (n != len[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int N;
  while (cin>>N, N) {
    vector<string> s(N);
    int num[] = {5, 7, 5, 7, 7};
    for (int i=0; i<N; i++) cin>>s[i];
    
    
    for (int i=0; i<N; i++) {
      bool ok=true;
      int idx=i;

      for (int j=0; j<5; j++) {
        int len = s[idx].size();
        ++idx;
        while (idx<N && len<num[j]) len+=s[idx++].size();

        if(idx > N) {
          ok = false;
          break;
        }
        
        if (len != num[j]) {
          ok=false;
        }
      }

      if (ok) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}

C++: main(){puts("hoge");}

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

int main (){
	int n;
	while(cin>>n && n){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			v[i]=s.size();
		}

		for(int i=0;i<n;i++){
			int count=0;
			int j=i;
			vector<bool> ok(5,false); 
			while(j<=n-1){
				count+=v[j];
				j++;
				if(count==5)ok[0]=true;
				if(ok[0] && count==12)ok[1]=true;
				if(ok[1] && count==17)ok[2]=true;
				if(ok[2] && count==24)ok[3]=true;
				if(ok[3] && count==31)ok[4]=true;
				if(ok[4]){
					cout<<i+1<<endl;
					goto END;
				}
			}
		}
		END:;
	}
}

C++: #include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
vector<int> v;
int f(int a){
    int t[5]={5,7,5,7,7};
    cnt=0;
    while(1){
        t[cnt]-=v[a];
        if(t[cnt]==0)cnt++;
        else if(t[cnt]<0)return 0;
        a++;
        if(cnt==5)return a+1;
    }
}
int main(void){
    while(1){
    cin>>n;
    v={};
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin>>s;
        v.push_back(s.size());
    }
    for(int i=0;i<n;i++){
        ans=f(i);
        if(ans!=0){
            cout<<i+1<<endl;
            break;
        }
    }
    }
}