import java.io.*;
import java.util.*;

public class ping_mb_assert {
    static void testIP(String ip) {
        StringTokenizer st = new StringTokenizer(ip, ".");
        assert st.countTokens() == 4;
        for (int i = 0; i < 4; i++) {
            String num = st.nextToken();
            try {
                int value = Integer.parseInt(num);
                assert 0 <= value && value <= 255 : "IP element is out of bounds";
                assert !num.startsWith("0") || num.length() == 1 : "Extra zeroes";
            } catch (NumberFormatException ex) {
                assert false : "Not a number";
            }
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("ping.in"));

        String fln = in.readLine(); 

        assert fln.startsWith("ping ") : "Should be started with \"ping\"";

        String ip = fln.substring(5);

        testIP(ip);

        String reply = "Reply from " + ip + " Time=";

        int min = Integer.MAX_VALUE, max = 0, av = 0;
        int lost = 0;

        for (int i = 0; i < 4; i++) {
            String ln = in.readLine();

            if (ln.equals("Time out")) {
                lost++;
            } else {
                assert ln.startsWith(reply);
                int time = Integer.parseInt(ln.substring(reply.length())); 
                assert 0 <= time && time <= 10000 : "Time is out of bounds";
                min = Math.min(min, time);
                max = Math.max(max, time);
                av += time;
            }
        }
        in.close();

        PrintWriter out = new PrintWriter("ping.out");
        out.println("Ping statistics for " + ip + ":");
        out.printf(" Packets: Sent = 4 Received = %d Lost = %d (%d%% loss)\n", (4 - lost), lost, 100 * lost / 4);
        if (lost < 4) {
            out.println("Approximate round trip times:");
            out.printf(" Minimum = %d Maximum = %d Average = %d\n", min, max, (int) (Math.round(av / (4.0 - lost))));
        }

        out.close();
    }
}