public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileInputStream inputStream = new FileInputStream(br.readLine());
int count = 1, max_count = 1;
ArrayList<Integer> el = new ArrayList<Integer>();
ArrayList<Integer> list = new ArrayList<Integer>();
HashSet<Integer> elements = new HashSet<Integer>();
while (inputStream.available()>0)
{
list.add(inputStream.read());
}
for (int i=0; i<list.size(); i++)
{
count=1;
for (int j=1; j<list.size(); j++)
{
if (list.get(i)==list.get(j))
count++;
}
if (count>max_count){
max_count=count;
}
}
for (int i=0; i<list.size(); i++)
{
count=1;
for (int j=1; j<list.size(); j++)
{
if (list.get(i)==list.get(j))
count++;
}
if (count==max_count)
{
elements.add(list.get(i));
}
for (int i=0; i<elements.toArray().length; i++)
System.out.print(elements.toArray()[i]+" ");
inputStream.close();
}
}package com.javarush.task.task18.task1803;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
/*
Самые частые байты
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileInputStream inputStream = new FileInputStream(br.readLine());
int count = 1, max_count = 1;
ArrayList<Integer> el = new ArrayList<Integer>();
ArrayList<Integer> list = new ArrayList<Integer>();
HashSet<Integer> elements = new HashSet<Integer>();
while (inputStream.available()>0)
{
list.add(inputStream.read());
}
for (int i=0; i<list.size(); i++)
{
count=1;
for (int j=1; j<list.size(); j++)
{
if (list.get(i)==list.get(j))
count++;
}
if (count>max_count){
max_count=count;
}
}
for (int i=0; i<list.size(); i++)
{
count=1;
for (int j=1; j<list.size(); j++)
{
if (list.get(i)==list.get(j))
count++;
}
if (count==max_count)
{
elements.add(list.get(i));
}
}
for (int i=0; i<elements.toArray().length; i++)
System.out.print(elements.toArray()[i]+" ");
//System.out.print(list.get(i)+" ");
inputStream.close();
}
}