#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll s;
ll _57577=0b10000001000000100001000000100001;

ll f(ll cnt){
	char ss[11];
	if(cnt){
		scanf(" %s",ss);
		ll t=f(cnt-1);
		s=s<<strlen(ss)|1;
		if((s&_57577)==_57577)return cnt;
		return t;
	}
	return -1;
}

int main(){
	ll cnt;
	while(scanf("%lld",&cnt),cnt){
		s=1;
		printf("%lld\n",cnt-f(cnt)+1);
	}
}
