import collections

def answer(s):
    YES = 'YES'
    NO = 'NO'
    dic = collections.Counter(s)
    vals = sorted([v for k,v in dic.items()])
    _max = vals[0]
    print(_max
    if _max < 2:
        return YES
    if len(keys) == 2:
        return NO
    if (_max-1)*2 > sum(vals[1:]):
        return YES
    if (_max-1)*2 == sum(vals[1:]):
        if _max == vals[1]:
            return NO
        return YES
s = input()
print(answer(s))