#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ifstream in("test.txt");
  std::cin.rdbuf(in.rdbuf());
  int n;
  string inp;
  int set[5] = {5, 12, 17, 24, 31};
  while (1) {
    cin >> n;
    if (n == 0) return 0;
    int shori[n];
    int size;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> inp;
      if (ans == -1) continue;
      size = inp.size();
      shori[i] = 0;
      for (int j = 0; j <= i; j++) {
        if (shori[j] == -1) continue;
        for (int l = 0; l < 5; l++) {
          if (shori[j] < set[l]) {
            if (size <= set[l] - shori[j]) {
              shori[j] += size;
              break;
            } else {
              shori[j] = -1;
              break;
            }
          }
        }
        if (shori[j] == set[4]) {
          cout << j + 1 << endl;
          ans = -1;
          break;
        }
      }
    }
  }
}
