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 <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int a[5] = {5, 7, 5, 7, 7};

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        vi v(n);
        rep(i, n) {
            string s;
            cin >> s;
            v[i] = s.size();
        }

        auto check = [&](int first){
            int t = 0;
            int j = 0;
            rep2(i, first, n) {
                if (t < a[j]) {
                    t += v[i];
                }
                if (t > a[j]) {
                    return false;
                }
                if (t == a[j]) {
                    j++;
                    t = 0;
                }
                if (j == 5) {
                    return true;
                }
            }
        };

        rep(i, n) {
            if (check(i)) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}

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