package JavaRush; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class Solution6 { public static void main(String[] args) { Scanner console = new Scanner(System.in); ArrayList<Integer> listNumbers = new ArrayList<>(); while (console.hasNextLine()) { String s = console.nextLine(); if (s.matches("^[-+]?\\d+(\\.\\d+)?$") && !s.isBlank()) { int interimValue = Integer.valueOf(s); listNumbers.add(interimValue); } else { if (listNumbers.size() > 1) { List<Integer> collect = listNumbers.stream().sorted().distinct().collect(Collectors.toList()); int a = collect.get(1); System.out.println(a); return; } else { throw new RuntimeException(); } } } } }