#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, w[430];
  string str, kari;
  cin >> n;
  while (n != 0) {
    fill_n(w, 430, 0);
    w[0] = 1;
    for (int i = 0; i < n; i++) {
      cin >> kari;
      if (i != 0) w[str.size()] = i + 1;
      str += kari;
    }
    w[str.size()] = n + 1;
    for (int i = 0; i <= str.size() - 31; i++) {
      if (w[i] != 0 && w[i + 5] != 0 && w[i + 12] != 0 && w[i + 17] != 0 &&
          w[i + 24] != 0 && w[i + 31] != 0) {
        cout << w[i] << endl;
        break;
      }
    }
    cin >> n;
  }
  return (0);
}
