#include <bits/stdc++.h>
using namespace std;
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
bool check(int x, vector<string> v) {
  int table[] = {5, 7, 5, 7, 7};
  int idx = 0, tmp = 0;
  for (int i = (x); i < (v.size()); i++) {
    tmp += v[i].size();
    if (tmp == table[idx]) {
      idx++;
      tmp = 0;
    } else if (tmp > table[idx]) {
      return false;
    }
    if (idx == 5) {
      return true;
    }
  }
  return false;
}
signed main() {
  int n;
  while (cin >> n, n) {
    vector<int> v;
    vector<string> s;
    v.push_back(0);
    for (int i = (0); i < (n); i++) {
      string t;
      cin >> t;
      s.push_back(t);
      v.push_back(t.size());
    }
    for (int i = (1); i < (n + 1); i++) {
      v[i] += v[i - 1];
    }
    int ans;
    for (ans = 0; ans < n + 1; ans++) {
      for (int j = (ans); j < (n + 1); j++) {
        int x = v[j] - v[ans];
        if (x > 31)
          continue;
        else if (x == 31 && check(ans, s))
          goto there;
      }
    }
  there:;
    cout << ans + 1 << endl;
    if (0) {
      cerr << "v";
      for (auto &e : (v)) cerr << " " << e;
      cerr << endl;
    };
  }
  return 0;
}
