#include <bits/stdc++.h>
using Ull = unsigned long long;
using Ll = long long;
template <typename T>
using Vec = std::vector<T>;
template <typename T, size_t L>
using Ary = std::array<T, L>;
namespace {
namespace meta {
namespace coming {
template <class... _Types>
using void_t = void;
template <class _Ty, _Ty _Val>
struct integral_constant {
  static constexpr _Ty value = _Val;
  using value_type = _Ty;
  using type = integral_constant;
  constexpr operator value_type() const noexcept { return (value); }
  constexpr value_type operator()() const noexcept { return (value); }
};
template <bool _Val>
using bool_constant = integral_constant<bool, _Val>;
template <bool _Test, class _Ty = void>
using enable_if_t = typename std::enable_if<_Test, _Ty>::type;
}  // namespace coming
namespace core {
template <class, class = void>
struct enable_std_begin_end : std::false_type {};
template <typename T>
struct enable_std_begin_end<
    T, coming::void_t<decltype(std::begin(std::declval<const T&>()),
                               std::end(std::declval<const T&>()))>>
    : std::true_type {};
template <class, class = void>
struct enable_adl_begin_end : std::false_type {};
template <typename T>
struct enable_adl_begin_end<
    T, coming::void_t<decltype(begin(std::declval<const T&>()),
                               end(std::declval<const T&>()))>>
    : std::true_type {};
}  // namespace core
template <typename T>
struct is_range : coming::bool_constant<core::enable_std_begin_end<T>::value ||
                                        core::enable_adl_begin_end<T>::value> {
};
template <class T, T num, class = std::nullptr_t>
struct is_positive : coming::bool_constant<(num >= 0)> {};
}  // namespace meta
inline namespace extension {
inline namespace container_io {
inline namespace in {
template <template <class...> class Container, class... Args,
          typename = meta::coming::enable_if_t<
              !std::is_same<Container<Args...>, std::string>::value>>
std::istream& operator>>(std::istream& is, Container<Args...>& container) {
  for (auto& elem : container) is >> elem;
  return is;
}
template <class T, size_t L>
std::istream& operator>>(std::istream& is, std::array<T, L>& container) {
  for (auto& elem : container) is >> elem;
  return is;
}
template <class T, size_t L>
std::istream& operator>>(std::istream& is, T (&ary)[L]) {
  for (int i{}; i < L; ++i) is >> ary[i];
  return is;
}
}  // namespace in
inline namespace out {
namespace settings {
const auto sepOfContainerElements{" "};
const auto sepOfContainer{"\n"};
}  // namespace settings
template <template <class...> class Container, class... Args,
          typename = meta::coming::enable_if_t<
              !std::is_same<Container<Args...>, std::string>::value>>
std::ostream& operator<<(std::ostream& os,
                         const Container<Args...>& container) {
  for (const auto& elem : container)
    os << elem << settings::sepOfContainerElements;
  return os;
}
template <class T, size_t L>
std::ostream& operator<<(std::ostream& os, const std::array<T, L> container) {
  for (const auto& elem : container)
    os << elem << settings::sepOfContainerElements;
  return os;
}
template <class T, size_t L,
          typename = meta::coming::enable_if_t<!std::is_same<T, char>::value>>
std::ostream& operator<<(std::ostream& os, const T (&ary)[L]) {
  for (const auto& elem : ary) os << elem << settings::sepOfContainerElements;
  return os;
}
template <template <class...> class Container1, class... Cont1Args,
          template <class...> class Container2, class... Cont2Args>
std::ostream& operator<<(
    std::ostream& os,
    const Container1<Container2<Cont2Args...>, Cont1Args...>& container) {
  for (const auto& elem : container) os << elem << settings::sepOfContainer;
  return os;
}
template <template <class...> class Container, class... Args, size_t L>
std::ostream& operator<<(std::ostream& os,
                         const std::array<Container<Args...>, L>& container) {
  for (const auto& elem : container) os << elem << settings::sepOfContainer;
  return os;
}
template <template <class...> class Container, class... Args, size_t L, class T>
std::ostream& operator<<(
    std::ostream& os, const Container<std::array<T, L>, Args...>& container) {
  for (const auto& elem : container) os << elem << settings::sepOfContainer;
  return os;
}
template <class T, size_t L1, size_t L2>
std::ostream& operator<<(std::ostream& os,
                         const std::array<std::array<T, L2>, L1> container) {
  for (const auto& elem : container) os << elem << settings::sepOfContainer;
  return os;
}
template <class T, size_t L1, size_t L2>
std::ostream& operator<<(std::ostream& os, const T (&ary)[L1][L2]) {
  for (size_t i{}; i < L1; ++i) os << ary[i] << settings::sepOfContainer;
  return os;
}
}  // namespace out
}  // namespace container_io
template <typename T, size_t L, typename Function>
void for_each(T (&ary)[L], Function lambda) {
  for (size_t i{}; i < L; ++i) lambda(static_cast<T&>(ary[i]));
}
}  // namespace extension
inline namespace util {
template <typename T>
void SetAll(T& container,
            typename T::value_type value = typename T::value_type{}) {
  for (typename T::reference content : container) content = value;
}
template <typename T, size_t L>
void SetAll(T (&ary)[L], T value) {
  for (size_t i{}; i < L; ++i) ary[i] = value;
}
template <typename T, typename U, size_t L1, size_t L2>
void SetAll(T (&ary)[L1][L2], U value) {
  for (size_t i{}; i < L1; ++i) SetAll(ary[i], value);
}
inline namespace ranges {
namespace core {
using namespace meta;
constexpr size_t recursion_limits{490};
template <int num, int divide>
struct is_divisible : coming::bool_constant<num % divide == 0> {};
template <int start, int end, int step>
struct is_finite_recursion_depth
    : coming::bool_constant<(start < end) && (step > 0) ||
                            (end < start) && (step < 0)> {};
template <int start, int end, int step>
struct is_valid_recursion_depth
    : coming::bool_constant<(end - start) / step <= recursion_limits> {};
template <int start, int end, int step>
struct is_valid_range
    : coming::bool_constant<
          (start == end) ||
          is_finite_recursion_depth<start, end, step>::value &&
              is_valid_recursion_depth<start, end, step>::value &&
              is_divisible<end - start, step>::value> {};
template <int start, int end, int step>
struct is_count_up_or_down
    : coming::bool_constant<is_valid_range<start, end, step>::value &&
                            end != start> {};
template <int start, int end, int step, class = void, int... Ary>
struct Range_Impl {
  static_assert(is_divisible<end - start, step>::value,
                "[ ! ] (end - start) is indivisible by step number [ ! ] "
                "割り切れないヨ！stepの値確認して！");
  static_assert(is_finite_recursion_depth<start, end, step>::value,
                "[ ! ] goes to infinite loop [ ! ] "
                "無限ループなっちゃうヨ！stepの符号逆じゃない？");
  static_assert(is_valid_recursion_depth<start, end, step>::value,
                "[ ! ] recursion depth is out of maximum limit [ ! ] "
                "再帰回数が大きくなりすぎｨ壊れちゃううう");
};
template <int start, int end, int step, int... Ary>
struct Range_Impl<
    start, end, step,
    meta::coming::enable_if_t<is_count_up_or_down<start, end, step>::value>,
    Ary...> : Range_Impl<start + step, end, step, void, Ary..., start> {};
template <int start, int end, int step, int... Ary>
struct Range_Impl<start, end, step, meta::coming::enable_if_t<start == end>,
                  Ary...> {
  static constexpr int value[(sizeof...(Ary) + 1)] = {Ary..., end};
};
}  // namespace core
template <size_t size, bool isReverse = false>
struct Iterate {
  static constexpr auto in =
      isReverse ? core::Range_Impl<static_cast<int>(size - 1), 0, -1>::value
                : core::Range_Impl<0, static_cast<int>(size - 1), 1>::value;
};
template <unsigned int upTo>
struct CountUp {
  static constexpr auto to =
      core::Range_Impl<0, static_cast<int>(upTo), 1>::value;
};
template <unsigned int downFrom>
struct CountDown {
  static constexpr auto from =
      core::Range_Impl<static_cast<int>(downFrom), 0, -1>::value;
};
template <int start, int containedEnd, int step = 0, typename = void>
struct Range {
  static constexpr auto& in =
      core::Range_Impl<start, containedEnd, step>::value;
};
template <int start, int containedEnd>
struct Range<start, containedEnd, 0> {
  static constexpr auto &in = core::Range_Impl < start, containedEnd,
                        meta::is_positive<int, containedEnd - start>::value
                            ? 1
                            : -1 > ::value;
};
}  // namespace ranges
}  // namespace util
inline namespace alg {
bool IsPrime(const Ull n) {
  switch (n) {
    case 0:
    case 1:
      return false;
    case 2:
      return true;
    default:
      if (n % 2 == 0) return false;
      for (Ull i{3}; i * i <= n; i += 2) {
        if (n % i == 0) return false;
      }
  }
  return true;
}
Ull EuclideanAlg(Ull n1, Ull n2) {
  if (n2 > n1) std::swap(n1, n2);
  Ull r;
  while ((r = n1 % n2) != 0) {
    n1 = n2;
    n2 = r;
  }
  return n2;
}
Ull LCM(const std::vector<Ull>& values) {
  if (values.size() == 0) return 0;
  if (values.size() == 1) return values[0];
  if (values.size() == 2)
    return values[0] * values[1] / EuclideanAlg(values[0], values[1]);
  auto mid = values.cbegin() + values.size() / 2;
  return LCM(std::vector<Ull>{LCM(std::vector<Ull>(values.begin(), mid)),
                              LCM(std::vector<Ull>(mid, values.end()))});
}
}  // namespace alg
void Solve();
}  // namespace
namespace {
bool isShortPhrase(const std::string& phrases) {
  constexpr Ary<char, 5> eachLength = {5, 7, 5, 7, 7};
  int sum{}, current{};
  for (int i = 0; i < phrases.size(); ++i) {
    sum += (int)phrases[i];
    if (sum == eachLength[current]) {
      if (current == eachLength.size() - 1) return true;
      ++current;
      sum = 0;
    }
  }
  return false;
}
void Solve() {
  int length;
  while (std::cin >> length, length != 0) {
    std::string phrases(40, '\0');
    for (int i{}; i < length; ++i) {
      std::string temp;
      std::cin >> temp;
      phrases[i] = temp.length();
    }
    for (int i{}; i < length - 4; ++i) {
      if (isShortPhrase(phrases.substr(i, phrases.size() - i))) {
        std::cout << i + 1 << std::endl;
        break;
      }
    }
  }
}
}  // namespace
