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.
import sys
import os

def file_input():
    f = open('CODE_FESTIVAL_2017Final/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    S=input()

    a=b=c=0

    for s in S:
        if s=='a':
            a+=1
        elif s=='b':
            b+=1
        else:
            c+=1

    if max(a,b,c)-min(a,b,c)<=1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

import sys
import os

def file_input():
    f = open('CODE_FESTIVAL_2017Final/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    S=input()

    a=b=c=0

    for s in S:
        if s=='a':
            a+=1
        elif s=='b':
            b+=1
        else:
            c+=1

    if max(a,b,c)-min(a,b,c)<=1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
