Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		s := make([]string, n)
		for i := 0; i < n; i++ {
			s[i] = io.NextLine()
		}
		w := [5]int{5, 7, 5, 7, 7}
		ans := 0
	OUTER:
		for i := 0; i < n; i++ {
			cnt, wc := 0, 0
			for j := i; j < n; j++ {
				wc += len(s[j])
				if wc == w[cnt] {
					cnt++
					wc = 0
					if cnt == 5 {
						ans = i + 1
						break OUTER
					}
				} else if wc > w[cnt] {
					break
				}
			}
		}
		io.Println(ans)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: 
#include <iostream>
#include <vector>
#include<stdio.h>
#include <time.h>
#include <string>
using namespace std;

int main() {

	while (1) {
		int n;
		cin >> n;
		if (n == 0)
			break;

		string word;
		int *length = new int[n];
		int key[5] = { 5,7,5,7,7 };
		for (int i = 0; i < n; i++) {
			cin >> word;
			length[i] = word.size();
			cout << length[i] << endl;
		}

		int count = 0;
		int section = 0;
		int index = 0;
		int output = 0;
		int start = 0;
		bool found = false;
		while (index != n) {
			index = output;
			output++;

			while (count <= 5) {
				if (key[count] > section) {
					section += length[index++];
				}
				else if (key[count] == section) {
					section = 0;
					count++;
				}
				else {
					break;
				}

				if (count == 5) {
					cout << output << endl;
					found = true;
				}
			}
			count = 0;
			section = 0;
			if (found)
				break;
		}
	}
	return 0;
}

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

int main(){
  int step,flag=0,n,l,x;
  while(1){
    cin >> n;
    if(n==0){break;}
    string w[n];
    for(int i=0;i<n;i++){
      cin >> w[i];
    }
    for(int i=0;i<n-5;i++){
      l=0;
      step=1;
      flag=0;
      x=i;
      while(1){
        if(flag==1){break;}
        l+=w[x].length();
        switch(step){
          case 1:
          if(l>5){flag=1;}
          else if(l==5){step++;}
          break;
          case 2:
          if(l>12){flag=1;}
          else if(l==12){step++;}
          break;
          case 3:
          if(l>17){flag=1;}
          else if(l==17){step++;}
          break;
          case 4:
          if(l>24){flag=1;}
          else if(l==24){step++;}
          break;
          case 5:
          if(l>31){flag=1;}
          else if(l==31){flag=2;}
          break;
        }
        if(flag==2){break;}
        x++;
      }
      if(flag==2){x=i+1;break;}
    }
    if(flag==2){cout << x << endl;}
  }
  return 0;
}

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

typedef pair<int, int> C;
typedef pair<int, C> iC;
#define fs first
#define sc second

string s;
bool overflow = false;

// index, number
pair<int, int> num(int i) {
  int ret = 0;
  while ('0' <= s[i] && s[i] <= '9') {
    int x = s[i] - '0';
    ret = 10 * ret + x;
    i++;
  }

  return make_pair(i, ret);
}

C multiplication(C a, C b) {
  return C(a.fs * b.fs - a.sc * b.sc, a.fs * b.sc + a.sc * b.fs);
}

C addition(C a, C b) {
  return C(a.fs + b.fs, a.sc + b.sc);
}

C subtraction(C a, C b) {
  return C(a.fs - b.fs, a.sc - b.sc);
}

void check_overflow(C a) {
  if (a.fs < -10000 || 10000 < a.fs) overflow = true;
  if (a.sc < -10000 || 10000 < a.sc) overflow = true;
}

// index, number
pair<int, C> dfs(int i = 0, C sum = C(0, 0)) {
  iC ans = make_pair(i, C(0, 0));

  while (i < s.size()) {
     if (s[i] == '(') {
      return dfs(i + 1);
    }

    if (s[i] == ')') {
      return iC(i, sum);
    }

    if (s[i] == '*') {
      iC a = dfs(i + 1);
      return iC(a.fs, multiplication(sum, a.sc));
    }

    if (s[i] == '+') {
      iC a = dfs(i + 1);
      return iC(a.fs, addition(sum, a.sc));
    }

    if (s[i] == '-') {
      iC a = dfs(i + 1);
      return iC(a.fs, subtraction(sum, a.sc));
    }

    if ('0' <= s[i] && s[i] <= '9') {
      pair<int, int> a = num(i);
      sum.fs += a.sc;
      i = a.fs;
    }

    if (s[i] == 'i') {
      return iC(i + 1, C(0, 1));
    }
  }
  return ans;
}

int main() {
  while (cin >> s) {
    iC ans = dfs();

    if (overflow) {
      cout << "overflow" << endl;
    } else {
      int real = ans.sc.fs;
      int imag = ans.sc.sc;

      if (real && imag) {
        printf("%d%c%di\n", real, (imag > 0 ? '+' : '-'), abs(imag));
      }
      else if (real) {
        printf("%d\n", real);
      }
      else if (imag) {
        printf("%di", imag);
      }
      else {
        puts("0");
      }
    }
  }
}