#include <bits/stdc++.h>
using namespace std;
int n, w[1000];
string str, kari;
int main() {
  cin >> n;
  while (n != 0) {
    fill_n(w, 1000, 0);
    w[0] = 1;
    for (int i = 0; i < n; i++) {
      cin >> kari;
      if (i != 0) w[str.size()] = i + 1;
      str += kari;
    }
    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) {
        if (i + 31 == str.size() || w[i + 31] != 0) {
          cout << w[i] << endl;
          break;
        }
      }
    }
    cin >> n;
  }
  return (0);
}
