Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`.  He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
from collections import defaultdict
def main():
    dd = defaultdict(int)
    dd["a"]=0;
    dd["b"]=0;
    dd["c"]=0;
    s = input()
    for i in range(len(s)):
        dd[s[i]]+=1 
    
    res = list(dd.values())
    if max(res)-min(res)>1:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

from collections import defaultdict
def main():
    dd = defaultdict(int)
    dd["a"]=0;
    dd["b"]=0;
    dd["c"]=0;
    s = input()
    for i in range(len(s)):
        dd[s[i]]+=1 
    
    res = list(dd.values())
    if max(res)-min(res)>1:
        print("NO")
    else:
        print("YES")

if __name__ == "__main__":
    main()
