#include <bits/stdc++.h>
using namespace std;
bool ok(vector<int> v, int start) {
  int nums[5] = {5, 7, 5, 7, 7};
  int i = 0;
  auto itr = v.begin() + start;
  while (i < 5) {
    for (; itr != v.end(); ++itr) {
      if (*itr == nums[i]) {
        i++;
        continue;
      } else if (*itr >= nums[i]) {
        return false;
      } else {
        nums[i] -= *itr;
      }
    }
    return true;
  }
}
int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      string str;
      cin >> str;
      v[i] = str.size();
    }
    int start = 0, tail = 0;
    int sum = 0;
    while (true) {
      if (tail == n) {
        cout << 0 << endl;
        break;
      }
      while (tail < n && sum < (5 + 7 + 5 + 7 + 7)) {
        tail++;
        sum = accumulate(v.begin() + start, v.begin() + tail, 0);
      }
      if (sum == (5 + 7 + 5 + 7 + 7)) {
        if (ok(v, start)) {
          cout << start << endl;
          break;
        } else {
          start++;
          sum = accumulate(v.begin() + start, v.begin() + tail, 0);
        }
      }
      while (sum > (5 + 7 + 5 + 7 + 7)) {
        start++;
        sum = accumulate(v.begin() + start, v.begin() + tail, 0);
      }
    }
  }
  return 0;
}
