main = interact $ unlines . map (show . short_phrase) . read' . lines
 where
  read' ("0":_) = []
  read' (n:xs) = take (read n) xs : read' (drop (read n) xs)

short_phrase fs = short_phrase' 1 [5,7,5,7,7] fs
 where
  short_phrase' s [] _ = s
  short_phrase' s (n:ns) (f:fs')
   | length f > n = short_phrase' (s+1) [5,7,5,7,7] (drop s fs)
   | length f == n = short_phrase' s ns fs'
   | otherwise = short_phrase' s (n-(length f):ns) fs'