#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool debug = false;
int haiku[45];
int num[6] = {5, 7, 5, 7, 7, 0};
void solve(int n) {
  int s = 0, e = 0, cnt = 0, sum = haiku[0];
  int dast = 0;
  int ans = 999999999;
  for (int i = 0; i < int(n - 5); i++) {
    dast = 0;
    s = e = i;
    while (s != n - 1 && e != n - 1) {
      if (debug)
        cout << "s: " << s << "  e:" << e << "  cheack( " << cnt
             << " ): " << num[cnt] << "  dast: " << dast << endl;
      if (cnt == 5) break;
      if (sum == num[cnt]) {
        cnt++;
        s = e = e + 1;
        sum = haiku[s];
      } else if (sum < num[cnt]) {
        e++;
        sum += haiku[e];
      } else if (sum > num[cnt]) {
        sum -= haiku[s];
        s++;
        dast++;
      }
    }
    dast += (n - e);
    ans = min(ans, dast);
  }
  cout << ans << endl;
}
int main() {
  int n;
  string s;
  while (cin >> n) {
    if (n == 0) break;
    for (int i = 0; i < int(n); i++) {
      cin >> s;
      haiku[i] = s.size();
    }
    solve(n);
  }
}
