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, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n)    rep(i, 0, n)
#define all(e)       (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

using namespace std;
using ll = long long;
template<class T>
using V = vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

V<int> tgt = {5, 7, 5, 7, 7};

class Solver {

public:
    Solver(int n) {
        N = n;
    }

    void solve() {
        REP(i, N) {
            string s;
            cin >> s;
            words.emplace_back(s.size());
        }
        int i = 0;
        while (!dfs(i, 0))i++;
        cout << i + 1 << endl;
    }

private:
    int N;
    V<int> words;

    bool dfs(int s, int p) {
        if (p == 5) {
            return true;
        }
        for (int len = 0, i = s; len <= tgt[p]; i++) {
            len += words[i];
            if (len == tgt[p]) {
                return dfs(i + 1, p + 1);
            }
        }

        return false;
    }
};

int main() {

    int N;
    while (cin >> N, N) {
        Solver(N).solve();
    }

    return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  int num_word;
  while(~scanf("%d",&num_word)) {
    if (num_word == 0) break;
    
    vector<string> words;
    for (int word_i = 0; word_i < num_word; word_i++) {
      string word;
      cin >> word;
      words.push_back(word);
    }
    int res = 0;
    for (int start = 0; start < num_word; start++) {
      bool has_end[256];
      memset(has_end, 0, sizeof(has_end));
      int pos = 0;
      for (int word_i = start; word_i < num_word; word_i++) {
	pos += words[word_i].size();
	has_end[pos] = true;
      }

      if (has_end[5] && has_end[5 + 7] && has_end[5 + 7 + 5]
	  && has_end[5 + 7 + 5 + 7] && has_end[5 + 7 + 5 + 7 + 7]) {
	res = start + 1;
	break;
      }
    }
    printf("%d\n",res);
  }
}

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

using namespace std;
vector<int> ans;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		
		string word[40];
		for(int i = 0;i < n;i++){
			cin >> word[i];
		}
		
		int tanku[] = {5,7,5,7,7};
		int ini = 0;
		for(int i = 0;i < n;i++){
			if(ini != 0) break;
			int kun = 0;
			int kulen = 0;
			for(int j = i;j < n;j++){
				kulen += word[j].size();
				if(kulen == tanku[kun]){
					kun++;
					kulen = 0;
					if(kun >= 5){
						ini = i+1;
						break;
					}
				}else if(kulen > tanku[kun]){
					break;
				}
			}
		}
		ans.push_back(ini);
	}
	
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

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

int main(){
  int n;
  while(cin >> n, n){
    vector<string> s(n);
    for(int i=0;i<n;i++)
      cin >> s[i];
    int ans=0;
    for(int f=0;f<n;f++){
      int p=f;
      bool ok=true;
      for(int k=0;k<5;k++){
	int nowl=0;
	while(nowl<check[k]){
	  nowl+=s[p].size();
	  p++;
	} 
	if(nowl!=check[k])
	  ok=false;
      }
      if(ok){
	ans=f+1;
	break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N;

  while(cin >> N && N) {
    vector<string> v;
    rep(i, N) {
      string s; cin >> s;
      v.push_back(s);
    }

    vector<int> wsize = {5,7,5,7,7};
    rep(i, N) {
      int idx = 0;
      bool ok = 0;
      int j = i;
      int curr = 0;
//      cout << "------" << endl;
      while(j < N) {
//        cout << v[j] << endl;
        if(curr + v[j].size() < wsize[idx]) {
          curr += v[j].size();
        } else if(curr + v[j].size() == wsize[idx]) {
          curr = 0;
          idx ++;
          if(idx == wsize.size()) {
            ok = 1;
            break;
          }
        } else {
          break;
        }
        j++;
      }
      if(ok) {
        cout << i + 1 << endl;
        break;
      }
    }

  }
  
  return 0;
}