#include <bits/stdc++.h>
using namespace std;
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template <class T, class U>
void chmin(T &x, const U &y) {
  x = min<T>(x, y);
}
template <class T, class U>
void chmax(T &x, const U &y) {
  x = max<T>(x, y);
}
struct prepare_ {
  prepare_() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  }
} prepare__;
const unsigned m = (1 << 6) | (1 << 13) | (1 << 18) | (1 << 25) | (1 << 30);
int n;
string s[40];
int main() {
  while (cin >> n, n) {
    for (ll i = (0); i < (ll)(n); i += (ll)(1)) cin >> s[i];
    for (ll i = (0); i < (ll)(n); i += (ll)(1)) {
      unsigned b = 0;
      for (ll j = (i); j < (ll)(n); j += (ll)(1)) {
        b <<= s[j].size();
        b |= 1 << s[j].size() - 1;
        if ((b & m) == m) {
          cout << i + 1 << endl;
          goto B;
        }
      }
    }
  B:;
  }
}
