#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n, j, count, i, ans;
    const int rule[5] = {5, 7, 5, 7, 7};
    string w[41];
    queue<pair<int, int> > kouho;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) cin >> w[i];
    j = 0;
    count = 0;
    i = 0;
    ans = 0;
    while (i < n) {
      count += w[i].length();
      if (w[i].length() <= 5) kouho.push(make_pair(i, i));
      if (count == rule[j]) {
        if (j >= 4) {
          cout << ans + 1 << endl;
          break;
        }
        count = 0;
        j++;
        i++;
      } else if (count > rule[j]) {
        count = 0;
        if (!kouho.empty()) {
          i = kouho.front().first;
          ans = kouho.front().second;
          kouho.pop();
          j = 0;
        } else {
          i++;
          j = 0;
          ans = i;
        }
      } else {
        i++;
      }
    }
  }
  return 0;
}
