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>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> vec(n);
        rep(i,n){
            string s;
            cin >> s;
            vec[i] = len(s);
        }
        rep(i,n){
            int flag = 0;
            int nw = 0;
            bool fl = true;
            srep(j,i,n){
                if(flag == 0){
                    nw += vec[j];
                    if(nw == 5){
                        flag = 1;
                        nw = 0;
                    }else if(nw > 5){
                        fl = false;
                        break;
                    }
                }else if(flag == 1){
                    nw += vec[j];
                    if(nw == 7){
                        flag = 2;
                        nw = 0;
                    }else if(nw > 7){
                        fl = false;
                        break;
                    }
                }else if(flag == 2){
                    nw += vec[j];
                    if(nw == 5){
                        flag = 3;
                        nw = 0;
                    }else if(nw > 5){
                        fl = false;
                        break;
                    }
                }else if(flag == 3){
                    nw += vec[j];
                    if(nw == 7){
                        flag = 4;
                        nw = 0;
                    }else if(nw > 7){
                        fl = false;
                        break;
                    }
                }else{
                    nw += vec[j];
                    if(nw == 7){
                        break;
                    }else if(nw > 7){
                        fl = false;
                        break;
                    }
                }
            }
            if(fl){
                cout << i+1 << "\n";
                break;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
#define DBG cout<<"!"<<endl;
vector<int> size;
int fin;
void dfs(int flag,int count,int i,int now){
  switch(flag){
  case 0:case 2:
    if(count+size[i]>5)
      return;
    if(count+size[i]==5){
      if(flag==0){	
	flag=1;
      }
      if(flag==2)
	flag=3;
    }
    if(flag==0||flag==2)
      dfs(flag,count+size[i],i+1,now);
    else
      dfs(flag,0,i+1,now);
    break;
  case 1:case 3:
    if(count+size[i]>7)
      return;
    if(count+size[i]==7){
      if(flag==1)
	flag=2;
      if(flag==3)
	flag=4;
    }
    if(flag==1||flag==3)
      dfs(flag,count+size[i],i+1,now);
    else
      dfs(flag,0,i+1,now);
    break;
  case 4:
    if(count+size[i]>7)
      return;
    if(count+size[i]==7){
      fin=1;
      cout<<now<<endl;
      return;
    }
    dfs(flag,count+size[i],i+1,now);
  }
}
int main(){
  int n;
  while(cin>>n,n!=0){
    string str2;
    for(int i=0;i<n;i++){
      cin>>str2;
      size.push_back(str2.size());
    }
    for(int i=0;i<n;i++){
      int flag;
      int cnt=size[i];
      int now=i+1;
      if(fin==1)
	break;
      if(cnt==5)
	flag=1;
      else
	flag=0;
      if(cnt>5)
	continue;
      dfs(flag,cnt,i+1,now);
    }
    size.clear();
  }
  return 0;
}

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

Pasharin;
int main(){
  int n;
  int a[]={5,7,5,7,7};
  while(cin>>n,n){
    string s[n];
    int x=0,y=0;
    for(int i=0;i<n;++i) cin>>s[i];
    int j=0;
    bool flag=false;
    for(j=0;j<n;++j){
      for(int i=j;i<n;++i){
        x+=(int)s[i].size();
        if(x==a[y]){
          x=0;
          y++;
          if(y==5){
            cout<<j+1<<endl;
            flag=true;
            break;
          }
        }
        else if(x>a[y]){
          x=0,y=0;
          break;
        }
      }
      if(flag) break;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
vector<int> cnt = {5, 12, 17, 24, 31};
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> w(n);
    for (int i = 0; i < n; i++){
      cin >> w[i];
    }
    vector<int> sum(n + 1, 0);
    for (int i = 0; i < n; i++){
      sum[i + 1] = sum[i] + w[i].size();
    }
    set<int> st;
    for (int i = 0; i <= n; i++){
      st.insert(sum[i]);
    }
    for (int i = 0; i < n; i++){
      bool ok = true;
      for (int j = 0; j < 5; j++){
        if (!st.count(sum[i] + cnt[j])){
          ok = false;
        }
      }
      if (ok){
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

C++: #include <bits/stdc++.h>

int n;
int L[64];
std::string str;

int main() {  
  for(;;) {
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      std::cin >> str;
      L[i] = str.size();
    }
    for(int i = 0; i < n; ++i) {
      int state = 0;
      int x = 0;
      int dx[5] = {5, 7, 5, 7, 7};
      for(int j = i; j < n; ++j) {
        x += L[j];
        if( x > dx[state] ) break;
        if( x == dx[state] ) {
          x = 0;
          state += 1;
          if( state == 5 ) {
            break;
          }            
        }
      }
      if( state == 5 ) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
            

  return 0;
}