// Online Java Compiler
// Use this editor to write, compile and run your Java code online

import java.util.*; 

/** Using the Java language, have function(str) take the str
 * parameter being passed and return the first word with the greatest number
 * of repeated letters.
 * 
 * For example: "Today, is the greatest day ever!" should return greatest
 * because it has 2 e's (and 2 t's) and it comes before ever which also
 * has 2 e's. If there are no words with repeating letters return -1.
 * 
 * Words will be separated by spaces. 
 * @author Conrad
 *
 */


class LetterCountI {  
  String function(String str) {
    String[] words = str.split(" ");
    String best = "";
    int max = 0;
    for (int i = 0; i < words.length; i++) {
      String curr = words[i];
      int count = helper(curr);
      if (count > max) {
        max = count;
        best = curr;
      }
    }
    if (max ==1) {
      return "-1";
    } else {
      System.out.println(best);
      return best;
    }
  }
  
  private int helper(String word) {
    HashMap<Character, Integer> map = new HashMap<Character, Integer>();
    for (int i = 0; i < word.length(); i++) {
      char temp = word.charAt(i);
      if (!map.containsKey(temp)) {
        map.put(temp, 1);
      } else {
        int prev = map.get(temp);
        map.put(temp, prev + 1);
      }
    }
    int max = 1;
    Iterator<Map.Entry<Character, Integer>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
      Integer curr = iterator.next().getValue();
      if (curr > max) {
        curr = max;
      }
    }
    System.out.println(max);
    return max;
  }
  
  public static void main (String[] args) {  
    // keep this function call here     
    Scanner  s = new Scanner(System.in);
    LetterCountI c = new LetterCountI();
    System.out.print(c.function(s.nextLine())); 
    s.close();
  }   
  
}