#include <bits/stdc++.h>
using namespace std;
vector<int> size;
int fin = 0;
void dfs(int flag, int count, int i, int now) {
  switch (flag) {
    case 0:
    case 2:
      if (count + size[i] > 5) return;
      if (count + size[i] == 5) {
        if (flag == 0) {
          flag = 1;
        }
        if (flag == 2) flag = 3;
      }
      if (flag == 0 || flag == 2)
        dfs(flag, count + size[i], i + 1, now);
      else
        dfs(flag, 0, i + 1, now);
      break;
    case 1:
    case 3:
      if (count + size[i] > 7) return;
      if (count + size[i] == 7) {
        if (flag == 1) flag = 2;
        if (flag == 3) flag = 4;
      }
      if (flag == 1 || flag == 3)
        dfs(flag, count + size[i], i + 1, now);
      else
        dfs(flag, 0, i + 1, now);
      break;
    case 4:
      if (count + size[i] > 7) return;
      if (count + size[i] == 7) {
        fin = 1;
        cout << now << endl;
        return;
      }
      dfs(flag, count + size[i], i + 1, now);
  }
}
int main() {
  int n;
  fin = 0;
  while (cin >> n, n != 0) {
    string str2;
    for (int i = 0; i < n; i++) {
      cin >> str2;
      size.push_back(str2.size());
    }
    for (int i = 0; i < n; i++) {
      int flag;
      int cnt = size[i];
      int now = i + 1;
      if (fin == 1) break;
      if (cnt == 5)
        flag = 1;
      else
        flag = 0;
      if (cnt > 5) continue;
      dfs(flag, cnt, i + 1, now);
    }
    size.clear();
  }
  return 0;
}
