# B - Palindrome-phobia

from collections import defaultdict

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

nl = lambda: list(map(int, input().split()))

s=si()

d=defaultdict(int)

for ss in s:

    d[ss]+=1

n=len(s)

t=set(s)

m=len(t)



if n==1:

    print('YES')

elif n==2:

    if m==1:

        print('NO')

    elif m==2:

        print('YES')

elif n==3:

    if m==1:

        print('NO')

    elif m==2:

        print('NO')

    elif m==3:

        print('YES')

elif n>=4:

    if m==1:

        print('NO')

    elif m==2:

        print('NO')

    elif m==3:

        if n%3==1:

            if max(d.values())==(n//3)+1:

                print('YES')

            else:

                print('NO')

        elif n%3==2:

            if max(d.values())==(n//3)+1:

                print('YES')

            else:

                print('NO')

        elif n%3==0:

            if max(d.values())==n//3:

                print('YES')

            else:

                print('NO')
s=eval(input())

from collections import Counter

c=Counter(s)

a_cnt=c["a"]

b_cnt=c["b"]

c_cnt=c["c"]

if abs(a_cnt-b_cnt)<=1 and abs(b_cnt-c_cnt)<=1 and abs(c_cnt-a_cnt)<=1:

  print("YES")

else:

  print("NO")
# B - Palindrome-phobia
from collections import defaultdict

si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
s = si()
d = defaultdict(int)
for ss in s:
    d[ss] += 1
n = len(s)
t = set(s)
m = len(t)
if n == 1:
    print("YES")
elif n == 2:
    if m == 1:
        print("NO")
    elif m == 2:
        print("YES")
elif n == 3:
    if m == 1:
        print("NO")
    elif m == 2:
        print("NO")
    elif m == 3:
        print("YES")
elif n >= 4:
    if m == 1:
        print("NO")
    elif m == 2:
        print("NO")
    elif m == 3:
        if n % 3 == 1:
            if max(d.values()) == (n // 3) + 1:
                print("YES")
            else:
                print("NO")
        elif n % 3 == 2:
            if max(d.values()) == (n // 3) + 1:
                print("YES")
            else:
                print("NO")
        elif n % 3 == 0:
            if max(d.values()) == n // 3:
                print("YES")
            else:
                print("NO")

s = eval(input())
from collections import Counter

c = Counter(s)
a_cnt = c["a"]
b_cnt = c["b"]
c_cnt = c["c"]
if abs(a_cnt - b_cnt) <= 1 and abs(b_cnt - c_cnt) <= 1 and abs(c_cnt - a_cnt) <= 1:
    print("YES")
else:
    print("NO")

-# B - Palindrome-phobia -from collections import defaultdict +s = eval(input()) +from collections import Counter -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -nl = lambda: list(map(int, input().split())) -s = si() -d = defaultdict(int) -for ss in s: -    d[ss] += 1 -n = len(s) -t = set(s) -m = len(t) -if n == 1: +c = Counter(s) +a_cnt = c["a"] +b_cnt = c["b"] +c_cnt = c["c"] +if abs(a_cnt - b_cnt) <= 1 and abs(b_cnt - c_cnt) <= 1 and abs(c_cnt - a_cnt) <= 1: -elif n == 2: -    if m == 1: -        print("NO") -    elif m == 2: -        print("YES") -elif n == 3: -    if m == 1: -        print("NO") -    elif m == 2: -        print("NO") -    elif m == 3: -        print("YES") -elif n >= 4: -    if m == 1: -        print("NO") -    elif m == 2: -        print("NO") -    elif m == 3: -        if n % 3 == 1: -            if max(d.values()) == (n // 3) + 1: -                print("YES") -            else: -                print("NO") -        elif n % 3 == 2: -            if max(d.values()) == (n // 3) + 1: -                print("YES") -            else: -                print("NO") -        elif n % 3 == 0: -            if max(d.values()) == n // 3: -                print("YES") -            else: -                print("NO") +else: +    print("NO")