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 <cmath>
#include <vector>
#include <string>
using namespace std;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> S(n+1);
        string str;
        cin >> str;
        S[0] = 0;
        S[1] = str.size();
        for(int i=2; i<=n; ++i) {
            cin >> str;
            S[i] = S[i-1] + str.size();
        }
        int tmp[5] = {5, 7, 5, 7, 7};
        int ret = 0;
        bool finished = false;
        for(int i=0; i<=n; ++i) {
            if(finished) break;
            int current=i;
            int current_haiku = 0;
            int offset=1;
            ret = i;
            while(current+offset <= S.size()) {
                if(S[current+offset] - S[current] == tmp[current_haiku]) {
                    current += offset;
                    offset = 1;
                    current_haiku++;
                    if(current_haiku == 5) {
                        finished = true;
                        break;
                    }
                } else if(S[current+offset] - S[current] > tmp[current_haiku]) {
                    break;
                } else {
                    offset++;
                }
            }
        }
        cout << ret+1 << endl;
    }
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi v(n);
    rep(i, n) {
      string s;
      cin >> s;
      v[i] = s.size();
    }
    int t[] = {0, 5, 7, 5, 7, 7};
    rep(i, n) {
      stack<int> s;
      loop(j, i, n) {
        if (!s.size()) {
          s.push(v[j]);
          continue;
        }
        if (s.top() == t[s.size()]) {
          if (s.size() == 5) {
            cout << i + 1 << endl;
            goto next;
          }
          s.push(v[j]);
          continue;
        }
        if (s.top() > t[s.size()]) {
          break;
        }
        s.top() += v[j];
      }
      if (s.size() == 5 && s.top() == t[s.size()]) {
        cout << i + 1 << endl;
        goto next;
      }
    }
  next:;
  }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

bool is_haiku_found(const vector<ll> &len, ll idx)
{
    ll a = 0;
    for (; idx < len.size(); ++idx) {
        a += len[idx];
        if (a == 5)break;
        else if (a > 5)return false;
    }
    ll b = 0;
    for (++idx; idx < len.size(); ++idx) {
        b += len[idx];
        if (b == 7)break;
        else if (b > 7)return false;
    }
    ll c = 0;
    for (++idx; idx < len.size(); ++idx) {
        c += len[idx];
        if (c == 5)break;
        else if (c > 5)return false;
    }
    ll d = 0;
    for (++idx; idx < len.size(); ++idx) {
        d += len[idx];
        if (d == 7)break;
        else if (d > 7)return false;
    }
    ll e = 0;
    for (++idx; idx < len.size(); ++idx) {
        e += len[idx];
        if (e == 7)break;
        else if (e > 7)return false;
    }
    return
        a == 5 &&
        b == 7 &&
        c == 5 &&
        d == 7 &&
        e == 7;
}
int main()
{
    while (true) {
        ll n = in();
        if (n == 0)break;
        vector<ll>len(n);
        REP(i, n)len[i] = in<string>().length();
        REP(i, n) {
            if (is_haiku_found(len, i)) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}