while True:
    try:
        s = input()
        dic, temp = {}, ''
        for c in s:
            if c.isdigit():
                temp += c
            else:
                if temp:
                    dic[temp] = len(temp)
                    temp = ''
        if temp:
            dic[temp] = len(temp)
        Max = max(dic.values())
        for k in dic:
            if dic[k] == Max:
                print(k, end='')
        print(',' + str(Max))
    except:
        break