PROGRAM Counts (Input,Output);

{Counts number of characters, words, and lines in Input}

VAR
  lines, words, chars : Integer;
  InWord : Boolean;
  Ch : Char;


BEGIN
  lines := 0;
  chars := 0;
  words := 0;

  WHILE NOT EOF DO
   Begin
    InWord := False;
    WHILE NOT EOLN DO
     Begin
      Read(Ch);
      chars := chars + 1;

      IF InWord THEN   (* currently in a word *)
       Begin
        IF Ch = ' ' THEN   (* and this is a blank *)
          InWord := False;   (* then no longer in a word *)
       End
      ELSE IF Ch <> ' ' THEN (* currently not in a word *)
       Begin                  (* and this is not a blank. *) 
        Words := Words + 1;  (* it is start of new word *)
        InWord := True;      (* indicate are now in a word *)
       End

     End;

    lines := lines + 1;
    Readln;
   End;

  Writeln('Lines= ',lines:1,'   Chars= ',chars:1,'   Words= ',words:1);
END.
