public class Solution {
    public static List<Thread> threads = new ArrayList<>(5);

    public static void main(String[] args) {
        threads.add(new TestThread());
        threads.add(new TestThread2());
        threads.add(new TestThread3());
        threads.add(new TestThread4());
        threads.add(new TestThread5());
    }

    public static class TestThread extends Thread {
        public void run() {
            while (true) {
            }
        }
    }

    public static class TestThread2 extends Thread {
        public void run() {
            try {
                throw new InterruptedException();
            } catch (InterruptedException e) {
                System.out.println("InterruptedException");
            }
        }
    }

    public static class TestThread3 extends Thread {
        public void run() {
            try {
                while (true) {
                    System.out.println("Ура");
                    Thread.currentThread().sleep(500);
                }
            } catch (InterruptedException e) {

            }
        }
    }

    public static class TestThread4 extends Thread implements Message {
        public void run() {
            showWarning();
        }

        public void showWarning() {
            Thread.currentThread().interrupt();
        }
    }

    public static class TestThread5 extends Thread {
        public void run() {
            int sum = 0;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

            try {
                while(true) {
                    String str = reader.readLine();
                    if (!str.equals("N")) {
                        sum += Integer.valueOf(str);
                    } else {
                        System.out.println(sum);
                        break;
                    }
                }

            } catch (IOException e) {
            }
        }
    }
}