// how to scan a file letter by letter

// as an example of what can be done, counts are computed
// for # lines, # chars, # words, and first 5 lines are printed

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(int argc, char *argv[]) {

  FILE *fIn = stdin;
  // fIn = fopen("someFile.txt", "r");

  int ch, prev = -1;
  int chars = 0; int lines = 0; int words = 0;
  while ((ch = fgetc(fIn)) != EOF) {
    chars++;
    if (ch == '\n') lines++;
    if (isspace(ch) && prev >= 0 &&
	! isspace(prev)) words++;

    if (lines < 5)
      printf("%c", ch);
    
    prev = ch;
  }
  printf("%d %d %d\n", lines, words, chars);

  // fclose(fIn);
  return 0;
}