int ch, count = 0;
while((ch = getchar()) != EOF)
   if(ch == '\n')
      ++count;
printf("%d\n", count);