#include<bits/stdc++.h>
char s[50],a[9]={1,6,8,6,8,8},i,j,p,n,q;
int main(){for(;scanf("%d\n",&n),n;printf("%d\n",i)){
for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=a[j++];q>1;q-=s[p++]);
}}