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 SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vi a(n);
        REP(i, n) {
            string s; cin >> s;
            a[i] = s.size();
        }

        vi nums = { 5, 7, 5, 7, 7};
        REP(i, n) {
            int cnt = 0;
            int idx = 0;
            bool valid = false;
            FOR(j, i, n) {
                cnt += a[j];
                if (cnt > nums[idx]) break;
                if (cnt == nums[idx]) {
                    cnt = 0;
                    if (++idx == 5) {
                        valid = true;
                        break;
                    };
                }
            }
            if (valid) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  while (1) {
    int chars=0;int tanku[5]={5,7,5,7,7};int block=0;//block???tanku??????????????´??°???v?????£??????leng???tanku??¨??????????????£?????´???
    int leng=0,istart=1;
    scanf("%d",&chars);
    if(chars==0){
      printf("\n");
      return 0;
    }
    std::vector<string> v(chars);
    for (size_t i = 0; i < chars; i++) {
      std::cin >> v[i];
    }

    //???????????§????????¨??\???
    //??????????????????

    for (size_t i = 0; block<=4; i++) {
      leng+=v[i].size();
      if (leng>tanku[block]) {
        block=0;leng=0;
        i=istart-1;istart++;
      }else if(leng==tanku[block]){
        block++;leng=0;
      }
    }
    printf("%d ",istart);
  }
  return 0;
}

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

using namespace std;

int main(void) {
	int n;
	int tan[5] = {5,7,5,7,7};
	cin >> n;
	while (n != 0) {
		vector<string> str(n);
		for (int i = 0; i < n; ++i) {
			cin >> str[i];
		}
		bool find = false;
		bool over = false;
		int ind = 0;
		int ln = 0;
		int ret;
		for (int i = 0; !find && i < n; ++i) {
			over = false;
			ind = 0;
			ln = 0;
			for (int j = i; !over && j < n; ++j) {
				if (ln + str[j].length() == tan[ind]) {
					if (ind == 4) {
						find = true;
						ret = i+1;
					}
					else {
						++ind;
						ln = 0;
					}
				}
				else if (ln + str[j].length() < tan[ind]) {
					ln += str[j].length();
				}
				else {
					over = true;
				}
			}
		}
		cout << ret << endl;
		cin >> n;
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(){
	while(1){
		LOOP:
		int n;
		scanf("%d",&n);
		if(!n) break;
		char w[40][11];
		int c[40];
		for(int i=0;i<n;i++){
			scanf("%s",w[i]);
			c[i]=strlen(w[i]);
		}
		int f[]={5,7,5,7,7};
		int k;
		int tmp;
		for(int i=0;i<n;i++){
			k=0;
			tmp=0;
			for(int j=i;j<n;j++){
				if(f[k]<tmp+c[j])
					break;
				tmp+=c[j];
				if(tmp==f[k]){
					k++;
					tmp=0;
				}
				if(k==5){
					printf("%d\n",i+1);
					goto LOOP;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int N;
  while(1){
    cin>>N;
    if(N==0){
      break;
    }
    VE V;
    FOR(i,0,N){
      string S;
      cin>>S;
      V.PB((int)S.size());
    }
    FOR(i,0,N){
      int sum=0;
      int now=i;
      while(sum<5){
        sum+=V[now];
        now++;
      }
      if(sum!=5){
        continue;
      }
      while(sum<12){
        sum+=V[now];
        now++;
      }
      if(sum!=12){
        continue;
      }
      while(sum<17){
        sum+=V[now];
        now++;
      }
      if(sum!=17){
        continue;
      }
      while(sum<24){
        sum+=V[now];
        now++;
      }
      if(sum!=24){
        continue;
      }
      while(sum<31){
        sum+=V[now];
        now++;
      }
      if(sum==31){
        cout<<i+1<<endl;
        break;
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  while(1){ 
    cin>>n;
    if(n==0)break;
    string str;
    int len[45];
    int i,j;
    int ans;

    rep(i,n){
      cin>>str;
      len[i]=str.size();
    }
    rep(i,n){
      int tanku[5]={5,7,5,7,7};
      int now=0;
      for(j=i;j<n;j++){
	if(len[j]>tanku[now])break;
	if(len[j]==tanku[now])now++;
	else tanku[now]-=len[j];
	if(now==5) goto ANS;
      }
    }
  ANS:cout<<i+1<<endl;
  }

}