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 <fstream>
#include <stdio.h>

using namespace std;


int ch_len(char ch[]){
    int cnt = 0;
    for(int i=0; i<20; i++){
        if(ch[i] == '\0' || ch[i] == '\n')break;
        cnt++;
    }
    return cnt;
}

int cir(char w[][20], int first, int n){
    
    int now_vocab = 0;
    int mojisu = 0;
    
    for(int i=first; i<n; i++){
        int len = ch_len(w[i]);
        
        
        mojisu+=len;
        switch(now_vocab){
            case 0:
                if(mojisu == 5){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >5){
                    return cir(w, first+1, n);
                }
                break;
            case 1:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
            case 2:
                if(mojisu == 5){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >5){
                    return cir(w, first+1, n);
                }
                break;
            case 3:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
            case 4:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
        }
        
        if(now_vocab >=5)return first;
    }
    
    return 0;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    /////////
    //write//
    /////////
    
    int res;
    
    while(1){
        int n;cin >> n;
        char w[50][20];//<50
        if(n==0)break;
        
        for(int i=0; i<n; i++){
            cin >> w[i];
        }
        
        res = cir(w, 0, n)+1;
        cout << res << endl;
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
    
    int array[5] = {5, 7, 5, 7, 7};

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<string> tanka(n);
        for(int i = 0; i < n; i++){
            cin >> tanka[i];
        }
        int ans;
        bool flag = false;
        for(int i = 0; i < n; i++){

            int counter = 0;
            int k = 0;
            for(int j = i; j < n; j++){
                counter += tanka[j].size();
                if(array[k] == counter){
                    counter = 0;
                    k++;
                }else if(array[k] < counter){
                    break;
                }

                if(k == 5){
                    ans = i + 1;
                    flag = true;
                    break;
                } 
            }

            if(flag) break;
        }

        cout << ans << endl;
    }
    return 0;
    
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vii;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip> vip;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 :1e9;
int main(){
	int n;
	while(cin>>n,n){
		vs in(n);
		rep(i,n)cin>>in[i];
		int q[]={5,7,5,7,7};
		rep(i,n){
			int t=0,I=i,s=0;
			while(I<n){
				s+=in[I].size();
				if(s>q[t])break;
				if(s==q[t]){
					t++;
					s=0;
				}
				if(t==5){
					cout<<i+1<<endl;
					goto end;
				}
				I++;
			}
		}
		end:;
	}
}

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

using namespace std;

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

bool search(int n,vector<int> &list,int p,int s){
  int c=0,i=p;
  if(s==5) return true;
  do{
    c+=list[i];
    i++;
  }while(c<range[s] && i<n);
  //  cout << c << endl;                                                                        
  // cout << "a " << s << endl;                                                                 
    if(c==range[s]) return search(n,list,i,s+1);
    else return false;
}

int main(){
  while(true){
    int n;
    cin >> n;
    if(n==0)break;
    string temp;
    vector<int> list(n,0);
    for(int i=0;i<n;i++){
      cin >>temp;
      list[i]=temp.length();
      //  cout << list[i] << endl;                                                              
    }
    bool flag;
    for(int i=0;i<n;i++){
      flag=search(n,list,i,0);
      if(flag){
        cout << i+1 << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int haiku[45];
int num[6]={5,7,5,7,7,0};

void solve(int n){
  int s=0,e=0,cnt=0,sum=haiku[0];
  int dast=0;
  int ans=INF;
  rep(i,n-5){
    dast=0;
    s=e=i;
    while(s!=n-1&&e!=n-1){
      if(debug)cout<<"s: "<<s<<"  e:"<<e<<"  cheack( "<<cnt<<" ): "<<num[cnt]<<"  dast: "<<dast<<endl;
      if(cnt==5)break;
      if(sum==num[cnt]){
	cnt++;s=e=e+1;sum=haiku[s];
      }else if(sum<num[cnt]){
	e++;sum+=haiku[e];
      }else if(sum>num[cnt]){
	sum-=haiku[s];s++;
	dast++;
      }
    }
    dast+=(n-e);
    ans=min(ans,dast);
  }
  cout<<ans<<endl;
}


int main(){
  int n;
  string s;
  while(cin>>n){
    if(n==0)break;
    rep(i,n){cin>>s;haiku[i]=s.size();}
    solve(n);
  }
}