while True:
    try:
        str_in = input()
        s=''
        for w in str_in:
            if w.isalpha():
                s+='*'
            else:
                s+=w
        s2=s.split('*')
        dic={}
        for w in s2:
            if w !='':
                dic[w]=len(w)
        max_value = max(dic.values())
        new_str =''
        for key in dic:
            if dic[key]==max_value:
                new_str+=key
        print(new_str+','+str(max_value))
               
    except:
        break