#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

while True:
    N = input()
    if N == 0:
        break
    lst = []
    for i in range(N):
        S = raw_input()
        lst.append(len(S))
    for i in range(N):
        S = 0
        ll = []
        for j in range(i, N):
            S += lst[j]
            ll.append(S)
        if 5 in ll and 12 in ll and 17 in ll and 24 in ll and 31 in ll:
            print i + 1
            break
    pass
