import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.Scanner;

public class ClientTCPSum {
	private final SocketChannel channel;
	
	public ClientTCPSum(String remoteHost, int remotePort) throws UnknownHostException, IOException {
		channel = SocketChannel.open();
		channel.connect(new InetSocketAddress(remoteHost, remotePort));
	}
	
	public void launch() throws IOException, InterruptedException {
		ByteBuffer bb = ByteBuffer.allocate(4);
		Scanner sc = new Scanner(System.in);
		for(int i=0 ; i<2 ; ++i)  {
			int op = sc.nextInt();
			bb.putInt(op);
			bb.flip();
			bb.limit(3);
			channel.write(bb);
			Thread.sleep(1000);
			bb.limit(4);
			channel.write(bb);
			bb.clear();
		}
		channel.read(bb);
		bb.flip();
		int res = bb.getInt();
		System.out.println("resultat = " + res);
	}
	
	public static void main(String[] args) throws NumberFormatException, UnknownHostException, IOException, InterruptedException {
		new ClientTCPSum(args[0], Integer.parseInt(args[1])).launch();
	}
}
