class Echo { public static void main(String args[]) throws java.io.IOException { int count = 0; StringBuffer line; int c; line = new StringBuffer(""); while ((c=System.in.read()) != -1){ if (c == '\n' ){ System.out.println(line); line= new StringBuffer(""); count++; } else line.append((char)c); } System.out.println("Input has " + count + " lines."); } }