#include <bits/stdc++.h>
using namespace std;
int make(int w, int p);
vector<string> a(40);
int main() {
  int n;
  scanf("%d", &n);
  while (n) {
    for (int t = 0; t < n; t++) {
      cin >> a[t];
    }
    for (int t = n; t < 40; t++) {
      a[t] = "";
    }
    int end = 0;
    int k = 0;
    for (k = 0; k < n; k++) {
      int q = k;
      if (make(q, 5) >= 1) {
        q = 1 + make(q, 5);
        if (make(q, 7) >= 1) {
          q = 1 + make(q, 7);
          if (make(q, 5) >= 1) {
            q = 1 + make(q, 5);
            if (make(q, 7) >= 1) {
              q = 1 + make(q, 7);
              if (make(q, 7) >= 1) {
                end = 1;
              }
            }
          }
        }
      }
      if (end == 1) break;
    }
    printf("%d\n", k + 1);
    scanf("%d", &n);
  }
}
int make(int w, int p) {
  int l = 0;
  int r = 0;
  l = a[w].size();
  if (l == p) {
    return w;
  } else {
    if (l < p) {
      r = make(w + 1, p - l);
      return r;
    } else {
      return -1;
    }
  }
}
