import java.util.*; public class P2975 { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuilder all = new StringBuilder(); if (in.hasNextLine()) { all.append(in.nextLine()); while (in.hasNextLine()) { all.append('\n'); all.append(in.nextLine()); } } Map cnt = new HashMap<>(); for (int i = 0; i < all.length(); i++) { char c = all.charAt(i); if (c == '\r' || c == '\n') continue; cnt.put(c, cnt.getOrDefault(c, 0) + 1); } char bestChar = 0; int best = -1; for (Map.Entry e : cnt.entrySet()) { char c = e.getKey(); int v = e.getValue(); if (v > best || (v == best && c < bestChar)) { best = v; bestChar = c; } } if (best < 0) { System.out.println(); System.out.println(0); } else { System.out.println(bestChar); System.out.println(best); } in.close(); } }