-- $Id: wc.lua,v 1.1 2001/05/14 16:33:47 doug Exp $
-- http://www.bagley.org/~doug/shootout/
-- contributed by Roberto Ierusalimschy

local cc,lc,wc = 0,0,0
for line in io.lines() do
  cc = cc + string.len(line)  -- count chars in the line
  local _,t = string.gsub(line, "%S+", "")   -- count words in the line
  wc = wc+t
  lc = lc+1            -- count lines
end
cc = cc + lc   -- count the newlines as characters

io.write(lc, " ", wc, " ", cc, "\n")