while True :

  n = int(eval(input()))

  if(n == 0) :

    break

  else :

    A = [5, 7, 5, 7, 7]

    ans = 0

    w = [len(eval(input())) for i in range(n)]

    for i in range(n) :

      k = 0

      s = 0

      for j in range(i, n) :

        s += w[j]

        if(s == A[k]) :

          s = 0

          k += 1

          if(k == 5) :

            ans = i + 1

            break

          elif(s > A[k]) :

            break

      if(ans != 0) :

        break

    print(ans)

while True :

    n = int(eval(input()))

    

    if(n == 0) :

        break

    

    else :

        S = [len(eval(input())) for i in range(n)]

        T = [5, 7, 5, 7, 7]

        ans = 0

        

        for i in range(n) :

            s = 0

            w = 0

            for j in range(i, n) :

                s += S[j]

                if(s == T[w]) :

                    s = 0

                    w += 1

                    if(w == 5) :

                        ans = i + 1

                        break

                    else :

                        pass

                elif(s > T[w]) :

                    break

                else :

                    pass

            if(ans != 0) :

                break

            else :

                pass

        print(ans)

        

while True:
    n = int(eval(input()))
    if n == 0:
        break
    else:
        A = [5, 7, 5, 7, 7]
        ans = 0
        w = [len(eval(input())) for i in range(n)]
        for i in range(n):
            k = 0
            s = 0
            for j in range(i, n):
                s += w[j]
                if s == A[k]:
                    s = 0
                    k += 1
                    if k == 5:
                        ans = i + 1
                        break
                    elif s > A[k]:
                        break
            if ans != 0:
                break
        print(ans)

while True:
    n = int(eval(input()))
    if n == 0:
        break
    else:
        S = [len(eval(input())) for i in range(n)]
        T = [5, 7, 5, 7, 7]
        ans = 0
        for i in range(n):
            s = 0
            w = 0
            for j in range(i, n):
                s += S[j]
                if s == T[w]:
                    s = 0
                    w += 1
                    if w == 5:
                        ans = i + 1
                        break
                    else:
                        pass
                elif s > T[w]:
                    break
                else:
                    pass
            if ans != 0:
                break
            else:
                pass
        print(ans)

-        A = [5, 7, 5, 7, 7] +        S = [len(eval(input())) for i in range(n)] +        T = [5, 7, 5, 7, 7] -        w = [len(eval(input())) for i in range(n)] -            k = 0 +            w = 0 -                s += w[j] -                if s == A[k]: +                s += S[j] +                if s == T[w]: -                    k += 1 -                    if k == 5: +                    w += 1 +                    if w == 5: -                    elif s > A[k]: -                        break +                    else: +                        pass +                elif s > T[w]: +                    break +                else: +                    pass +            else: +                pass