import java.net.*;
import java.io.*;

public class BeerServer1 {
  public static void main(String args[]) throws Exception {
    ServerSocket ssock=new ServerSocket(1234);
    System.out.println("Listening");
    Socket sock=ssock.accept();
    ssock.close(); // no more connects

    PrintStream pstream=new PrintStream(
       sock.getOutputStream());
// ask for count
    pstream.print("count? ");
    BufferedReader input =
      new BufferedReader( new InputStreamReader(
         sock.getInputStream()));
// read and parse it
    String line = input.readLine();
    pstream.println("");
    int count = Integer.parseInt(line);
    for (int i=count;i>=0;i--) {
      pstream.println(i + " bottles of beer on the wall");
      }
    pstream.close();
    sock.close();
    }
  }
