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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> n;
        if (n == 0) break;
        string s[45];
        rep(i, n) cin >> s[i];
        int ans = 0;
        rep(i, n) {
            bool go = false;
            int k = i;
            bool ok[5] = {};
            while (k < n) {
                int cnt = 0;
                bool check = false;
                int num = 0;
                int idx = 0;
                rep(l, 5) {
                    if (!ok[l]) {
                        check = true;
                        if (l == 4) {
                            idx = l;
                            num = 7;
                            break;
                        }
                        else if (l % 2 == 0) {
                            idx = l;
                            num = 5;
                            break;
                        }
                        else {
                            idx = l;
                            num = 7;
                            break;
                        }
                    }
                }
                if (!check) {
                    go = true;
                    break;
                }
                bool back = false;
                while (k < n) {
                    cnt += s[k].size();
                    k++;
                    if (cnt == num) {
                        ok[idx] = true;
                        break;
                    }
                    else if (cnt > num) {
                        back = true;
                        break;
                    }
                }
                if (back) break;
                check = false;
                rep(l, 5) if (!ok[l]) check = true;
                if (!check) {
                    go = true;
                    break;
                }
            }
            if (go) {
                ans = i + 1;
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3112