Go: // Short Phrase(短句)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1601&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		n := nextInt(sc)
		if n == 0 {
			break
		}

		var words []string
		for i := 0; i < n; i++ {
			words = append(words, nextString(sc))
		}

		res := 0
		for i := 0; i < n; i++ {
			tmpWords := words[i:]
			ok := checkRule(tmpWords, 0)
			if ok {
				res = i + 1
				break
			}
		}

		fmt.Println(res)
	}
}

var rule = [5]int{5, 7, 5, 7, 7}

func checkRule(words []string, depth int) bool {
	var shortPhrase = ""
	var i = depth

	if depth == 5 {
		return true
	}

	for len(words) > 0 {
		shortPhrase += words[0]
		words = words[1:]

		if rule[i] == len(shortPhrase) {
			return checkRule(words, i+1) // 短句のルールを満たしたので次の文節へ
		} else if rule[i] < len(shortPhrase) {
			return false // 文節の語数オーバー
		}
	}

	return false // 文節を満たす単語が足りない
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

using namespace std;

bool ok(vector<int> v, int start) {
    int nums[5] = { 5, 7, 5, 7, 7 };
    int i = 0;
    auto itr = v.begin() + start;
    while (i < 5) {
        for (; itr != v.end(); ++itr) {
            if (*itr == nums[i]) {
                i++;
                continue;
            }
            else if (*itr >= nums[i]) {
                return false;
            }
            else {
                nums[i] -= *itr;
            }
        }
        return true;
    }
}

int main()
{
    int n;
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }

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

        int start = 0, tail = 0;
        int sum = 0;
        while (true) {
            if (tail == n) {
                cout << 0 << endl;
                break;
            }

            while (tail < n && sum < (5 + 7 + 5 + 7 + 7)) {
                tail++;
                sum = accumulate(v.begin() + start, v.begin() + tail, 0);
            }

            if (sum == (5 + 7 + 5 + 7 + 7)) {
                if (ok(v, start)) {
                    cout << start << endl;
                    break;
                }
                else {
                    start++;
                    sum = accumulate(v.begin() + start, v.begin() + tail, 0);
                }
            }
            while (sum > (5 + 7 + 5 + 7 + 7)) {
                start++;
                sum = accumulate(v.begin() + start, v.begin() + tail, 0);
            }
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;


/*--------------------template--------------------*/

int main()
{
	while (1) {
	NEXT:
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			vi v;
			REP(i, n)
			{
				cin >> s;
				v.push_back(s.size());
			}
			cnt = 0;
			for (int i = cnt; i < n; i++) {
				ll j = cnt;
				ll flag = 0;
				sum = 0;
				while (1) {
					sum += v[j];
					j++;
					if (flag == 0) {
						if (sum == 5) {
							sum = 0;
							flag = 1;
						}
						if (sum > 5) {
							break;
						}
					} else if (flag == 1) {
						if (sum == 7) {
							sum = 0;
							flag = 2;
						}
						if (sum > 7) {
							break;
						}
					} else if (flag == 2) {
						if (sum == 5) {
							sum = 0;
							flag = 3;
						}
						if (sum > 5) {
							break;
						}
					} else if (flag == 3) {
						if (sum == 7) {
							sum = 0;
							flag = 4;
						}
						if (sum > 7) {
							break;
						}
					} else if (flag == 4) {
						if (sum == 7) {
							cout << cnt + 1 << endl;
							goto NEXT;
						}
						if (sum > 7) {
							break;
						}
					}
				}
				cnt++;
			}
		}
	}
}

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:;
  }
}