#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    vector<string> w(n);
    int tan[] = {5, 7, 5, 7, 7};
    for (int i = 0; i < n; i++) {
      cin >> w[i];
    }
    int j = 0;
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += w[i].size();
      if (sum > tan[j]) {
        sum = w[i].size();
        j = 0;
        ans = i;
      }
      if (sum < tan[j]) continue;
      if (sum == tan[j]) {
        if (j == 4)
          break;
        else {
          j++;
          sum = 0;
        }
      }
    }
    cout << ans + 1 << endl;
  }
}
