package com.javarush.task.task18.task1823;

import java.io.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/*
Нити и байты
*/

public class Solution {
    public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
    public static void main(String[] args) throws IOException, InterruptedException {
       BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String Str=reader.readLine();
        while(!Str.equals("exit")) {
            Str=reader.readLine();
            ReadThread rd = new  ReadThread(Str);
            rd.start();
    }
        reader.close();
    }

    public static class ReadThread extends Thread {
        public String fileName;
      public ReadThread(String fileName) throws IOException {
        this.fileName=fileName;
        }
        public void run(){
            HashMap<Integer, Integer> Tempmap = new HashMap<>();
            try {
                FileInputStream file = new FileInputStream(fileName);
                while (file.available() > 0) {
                    int data = file.read();
                    Integer count = Tempmap.get(data);
                    Tempmap.put(data, count == null ? 1 : count + 1);
                }file.close();
            }
            catch (FileNotFoundException e){

            } catch (IOException e) {
                e.printStackTrace();
            }
           for (Map.Entry<Integer, Integer> item : Tempmap.entrySet()) {
                if (item.getValue() == Collections.max(Tempmap.values())) {//выводим Максимальное значение мапы
                    resultMap.put(fileName, item.getKey());
                }
            }
        }
  }
    }