Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')

ans = ''
if a == b == c - 1:
  ans = 'YES'
elif a == b - 1 == c:
  ans = 'YES'
elif a - 1 == b == c:
  ans = 'YES'
elif a == b == c + 1:
  ans = 'YES'
elif a == b + 1 == c:
  ans = 'YES'
elif a + 1 == b == c:
  ans = 'YES'
else:
  ans = 'NO'
print(ans)

# Example run
# Input:
+|Er
# Output:
NO
import sys
#input = sys.stdin.buffer.readline
from collections import Counter

def main():
    s = list(input())
    l = len(s)
    c = Counter(s)
    c = list(c.values())
    
    c.sort(reverse=True)

    for num in c:
        if num != -(-l//3):
            print("NO")
            exit()
        l -= 1

    print("YES")

if __name__ == "__main__":
    main()


# Example run
# Input:
-507621088
# Output:
NO
s=list(input())

a=s.count('a')
b=s.count('b')
c=s.count('c')

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

else:
    print('NO')
   



# Example run
# Input:
2<jugY\e+
# Output:
YES
s = input() #sys.stdin.readlineは最後が改行

from collections import Counter

c = Counter(s)
cm = c.most_common()

if len(c)==1:
    if len(s)==1:
        print('YES')
    else:
        print('NO')
    exit()

if len(c)==2:
    if len(s)==2:
        print('YES')
    else:
        print('NO')
    exit()

if len(c)==3:
    aa = cm[0][1]
    bb = cm[1][1]
    cc = cm[2][1]
    if aa-cc<2:
        print('YES')
    else:
        print('NO')


# Example run
# Input:
d=C>#:p
# Output:
#!/usr/bin/env python3
#CODEFESTIVAL 2017 B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
c = list(Counter(s).items())
c.sort(key = itemgetter(1))
if len(s) == 1:
    print('YES')
elif len(s) == 2:
    if s[0] == s[-1]:
        print('NO')
    else:
        print('YES')
else:
    if len(c) != 3:
        print('NO')
    else:
        if c[-1][1] - c[0][1] <= 1:
            print('YES')
        else:
            print('NO')


# Example run
# Input:
.SD+<
# Output:
NO
S = input()
temp = ["a", "b", "c"]
abc = [S.count(x) for x in temp]
abc.sort(reverse=True)
if abc.count(0) == 1:
    if len(S) == 2:
        print("YES")
    else:
        print("NO")
elif abc.count(0) == 2:
    if len(S) == 1:
        print("YES")
    else:
        print("NO")
elif abc[0] == abc[1] == abc[2]:
    print("YES")
elif abc[0] == abc[1] == abc[2]+1:
    print("YES")
elif abc[0] == abc[1]+1 == abc[2]+1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
|Au
# Output:
YES
s=input()
if max(s.count("a"),s.count("b"),s.count("c"))-min(s.count("a"),s.count("b"),s.count("c"))<=1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
'gg[Y)lx&
# Output:
YES
s = input()
d = {}
st = set()
for c in s:
    if(c not in d): d[c] = 0
    else: d[c] += 1
    st.add(c)

if(len(st) == 1):
    if(len(s) == 1): print("YES")
    else: print("NO")

elif(len(st) == 2):
    if(d[list(st)[0]] == d[list(st)[1]]): print("YES")
    else: print("NO")

else:
    mx = 0
    no = False
    for k in d:
        mx = max(mx, d[k])
        if(d[k]+1 < mx): flg = True
    if(no): print("NO")
    else: print("YES")

# Example run
# Input:
1.759026029100778e-41
# Output:
YES
s=input()
from collections import Counter
sc=Counter(s)
for a in sc:
    if sc[a]>len(s)//2:
        print("NO")
        exit()
print("YES")


# Example run
# Input:
abTcLg*7.
# Output:
YES
import collections
def main():
    s = list(input())
    tmp = len(set(s))
    c = collections.Counter(s)

    a_n = c['a']
    b_n = c['b']
    c_n = c['c']
    ans = []
    if a_n >= b_n and a_n >= c_n:
        ans.append('a')
        a_n -= 1
        if b_n >= c_n:
            ans.append('b')
            b_n -= 1
        else:
            ans.append('c')
            c_n -= 1
    elif b_n >= a_n and b_n >= c_n:
        ans.append('b')
        b_n -= 1
        if a_n >= c_n:
            ans.append('a')
            a_n -= 1
        else:
            ans.append('c')
            c_n -= 1
    else:
        ans.append('c')
        c_n -= 1
        if b_n >= a_n:
            ans.append('b')
            b_n -= 1
        else:
            ans.append('a')
            a_n -= 1


    while True:
        if (ans[-1] == 'a' and ans[-2] == 'b') or (ans[-1] == 'b' and ans[-2] == 'a'):
            if c_n > 0 :
                c_n -= 1
                ans.append('c')
            else:
                if a_n == 0 and b_n == 0:
                    break
                print('NO')
                return
        elif (ans[-1] == 'c' and ans[-2] == 'b') or (ans[-1] == 'b' and ans[-2] == 'c'):
            if a_n > 0:
                a_n -= 1
                ans.append('a')
            else:
                if c_n == 0 and b_n == 0:
                    break
                print('NO')
                return
        else:
            if b_n > 0:
                b_n -= 1
                ans.append('b')
            else:
                if a_n == 0 and c_n == 0:
                    break
                print('NO')
                return
    print('YES')


if __name__ == '__main__':
    main()


# Example run
# Input:
tf}oE
# Output:
NO
import math

S = list(input())
ls = len(S)
na = S.count("a")
nb = S.count("b")
nc = ls - na - nb
mi = min(na, nb, nc)

if ls == 1:
    print("YES")
    exit()
elif ls == 2:
    if S[0] == S[1]:
        print("NO")
    else:
        print("YES")

temp = math.ceil(ls / 4)
if mi >= temp:
    print("YES")
else:
    print("NO")

# Example run
# Input:
-7517
# Output:
NO
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')

if abs(a-b)<=1 and abs(a-c)<=1:
    print('YES')
else:
    print('NO')


# Example run
# Input:
cUc&W
# Output:
NO
S = input()
s = set(S)
count = [S.count(i) for i in s]
if len(S) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
elif (max(count)-min(count) <= 1 and len(s) == 3) or len(S) == 1:
    print('YES')
else:
    print('NO')


# Example run
# Input:
|@`(
# Output:
NO
s = input()

a, b, c = s.count('a'), s.count('b'), s.count('c')
cnt = max(abs(a - b), abs(b - c), abs(c - a))
print('YES' if cnt <= 1 else 'NO')


# Example run
# Input:
/5<aR[-
# Output:
YES
from collections import Counter
s = dict(Counter(input()))
a = [x for x in s.values()]
ans = "NO"
if len(a) == 1 and a[0] == 1: ans = "YES"
elif len(a) == 3:
    A = (2 + (a[0]-2) * 2) // 2
    if a[1] >= A and a[2] >= A: ans = "YES"
print(ans)

# Example run
# Input:
)(MWF
# Output:
NO
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 2 and len(t) ==2:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")



# Example run
# Input:
tN_j
# Output:
NO
# https://atcoder.jp/contests/cf17-final/submissions/12544627
# B - Palindrome-phobia
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    a = s.count("a")
    b = s.count("b")
    c = s.count("c")

    print("YES" if max(a, b, c) <= min(a, b, c) + 1 else "NO")


if __name__ == '__main__':
    resolve()


# Example run
# Input:
;Zovz
# Output:
YES
# import bisect
from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    len_s = len(s)
    cnt = Counter(s)
    a_num = cnt["a"]
    b_num = cnt["b"]
    c_num = cnt["c"]

    least = min(a_num, b_num, c_num)

    if a_num - least <= 1 and b_num - least <= 1 and c_num - least <= 1:
        print('YES')
    else:
        print('No')


if __name__ == '__main__':
    main()

# Example run
# Input:
P}lXg<'3O
# Output:
YES
s=list(input())
n=len(s)
if len(set(s))==1:
    print("NO")
    exit()
    
x,y,z=0,0,0

for i in s:
    if i=="a":
        x+=1
    elif i=="b":
        y+=1
    else:
        z+=1
lis=[x,y,z]

if n%2==0:
    
    lis=sorted(lis,reverse=True)
    if lis[0]>sum(lis[1:])+1:
        print("NO")
    else:
        print('YES')
else:
    if len(set(s))==2:
        print("NO")
    else:
        for i in lis:
            if i%2==1:
                odd=i
        for i in lis:
            if i%2==0:
                if i<odd-1 or odd+1<i:
                    print("NO")
                    exit()
        print("YES")


# Example run
# Input:
E91W<+
# Output:
NO
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
  print("NO")
  exit()
if k == 2:
  if len(s) == 2:
    print("YES")
  else:
    print("NO")
  exit()
minabc = sorted([a, b, c])[1]
a = max(0, a - minabc)
b = max(0, b - minabc)
c = max(0, c - minabc)
# print(a, b, c, k)
if a <= 1 and b <= 1 and c <= 1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
@@)}rTVtQ
# Output:
YES
S = input()
na = S.count("a")
nb = S.count("b")
nc = S.count("c")

nall = na+nb+nc
mx = max(na,nb,nc)
mn = min(na,nb,nc)
rest = nall - mx
if len(S) >= 3 and mx - rest == 1 and mn == 0:
    print("NO") 
else:
    if mx - rest >= 2:
        print("NO")
    else:
        print("YES")

# Example run
# Input:
0A}C.
# Output:
YES
s = list(map(str,input()))
from collections import Counter
l = Counter(s)
abc = [l["a"],l["b"],l["c"]]
mx = max(abc)
mi = min(abc)
md = sum(abc)-mx-mi
if mx == 1 and mi == md == 0:
  print("YES")
elif 0 in abc:
  print("NO")
elif mx-mi == 1 or mx-mi == 0:
  print("YES")
else:
  print("NO")

# Example run
# Input:
R[-
# Output:
NO
*c, = map(input().count, "abc")
print(["YES","NO"][max(c)-min(c) > 1])

# Example run
# Input:
5~W'fMa)B
# Output:
YES
s = input()

na = nb = nc = 0
for c in s:
  if c == 'a':
    na += 1
  if c == 'b':
    nb += 1
  if c == 'c':
    nc += 1

if abs(na - nb) < 2 and abs(na - nc) < 2 and abs(nb - nc) < 2:
  print("YES")
else:
  print("NO")


# Example run
# Input:
zXv9
# Output:
YES
from collections import Counter
s = input().rstrip()
n = len(s)
cnt = Counter(s)
a = list(cnt.values())
while len(a) < 3:
    a.append(0)
a.sort()
if a[2] - a[0] < 2:
    print("YES")
else:
    print("NO")

# Example run
# Input:
1014096062
# Output:
YES
from collections import Counter
S = str(input())
CS = Counter(S)
V = list(CS.values())
ans = 'YES'
if len(V) == 1:
  ans = 'NO'
elif len(V) == 2:
  if V[0] >= V[1]+1:
    ans = 'NO'
else:
  if 2*V[0] <= V[1]+V[2]:
    ans = 'NO'

print(ans)

# Example run
# Input:
*Q<ju
# Output:
NO
S=input()
n=[S.count(x)for x in"abc"]
print("YNEOS"[max(n)-min(n)>1::2])

# Example run
# Input:
9'r
# Output:
YES
S = input()
C = [S.count('a'), S.count('b'), S.count('c')]
if (len(set(list(S))) == 3 and max(C) - min(C) < 2) or len(S) == 1 or (len(S) == len(set(list(S))) == 2):
    print('YES')
else:
    print('NO')

# Example run
# Input:
}Q!*
# Output:
NO
S = input()
s = set(S)
count = [S.count(i) for i in s]
if max(count)-min(count) <= 1 and len(set(S)) == 3:
    print('YES')
else:
    print('NO')


# Example run
# Input:
2.)t.
# Output:
NO
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
if max(a, b, c) - min(a, b, c) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
NR'(:s!sy
# Output:
YES
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  if s[0]!=1:
    print("NO")
    exit()
  else:
    print("YES")
    exit()
a = s[0]
if len(s)==2:
  if s[0]==1 and s[1]==1:
    print("YES")
    exit()
  else:
    print("NO")
    exit()
for i in s:
  if a==i or a==i+1:
    continue
  else:
    print('NO')
    exit()
else:
  print("YES")


# Example run
# Input:
hxe
# Output:
YES
S=input()
a,b,c=S.count("a"),S.count("b"),S.count("c")
print("YES" if max(a,b,c)-min(a,b,c)<= 1 else "NO")

# Example run
# Input:
)iNo/$
# Output:
YES
from collections import Counter

S = input()
c = Counter(S)

if len(c) == 3 and max(c.values()) - min(c.values()) <= 1:
    print("YES")
elif len(c) == 2 and len(S) == 2:
    print("YES")
elif len(c) == 1 and len(S) == 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
CWE91W<+
# Output:
NO
from collections import Counter

S = input()
d = Counter(S).values()
if len(d) == 3 and max(d) - min(d) <=1:
  ans = "YES"
else:
  ans = "NO"
print(ans)

# Example run
# Input:
7VdH
# Output:
NO
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
if min(a,b,c)!=0 and max(a,b,c)-min(a,b,c)<=1:
    print("YES")
elif a+b+c==max(a,b,c) and max(a,b,c)==1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
>#:pjLk(&
# Output:
NO
import collections

S = list(input())
c = collections.Counter(S)
ans = 'NO'
ma = c.most_common()[0][1]
if (len(c) == 3):
  if (c.most_common()[1][1] >= ma - 1) and (c.most_common()[2][1] >= ma - 1):
    ans = 'YES'
print(ans)

# Example run
# Input:
e3zvshd]
# Output:
NO
import collections
s = "abc" + input()
cnt = collections.Counter(s)
a, b, c = cnt["a"], cnt["b"], cnt["c"]
if abs(a-b) < 2 and abs(c-b) < 2 and abs(a-c) < 2:
    print("YES")
else:
    print("NO")

# Example run
# Input:
/X&w)1
# Output:
YES
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
l1=[a,b,c]
l1.sort()
if l1[0]==0 and l1[1]==1 and l1[2]==1:
    print("YES")
elif min(a,b,c)!=0 and max(a,b,c)-min(a,b,c)<=1:
    print("YES")
elif a+b+c==max(a,b,c) and max(a,b,c)==1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
09{=
# Output:
NO
from collections import Counter
def solve():
    s = list(input())
    
    abc = Counter(s)
    
    if len(abc.values()) < 3:
        if sum(abc.values()) < 3:
            return 'YES'

        return 'NO'
    else:
        m = min(abc.values())
        two = []
        for i in abc.values():
                two.append(i-m)
        
        if sum(two) < 3:
            if two.count(0) == 2:
                return 'NO'
            return 'YES'

        return 'NO'

print(solve())


# Example run
# Input:
xgI8vLA
# Output:
YES
S = input()
na = S.count("a")
nb = S.count("b")
nc = S.count("c")

n_kind = len(set(S))
nall = na+nb+nc
mx = max(na,nb,nc)
mn = min(na,nb,nc)
rest = nall - mx

if len(S) == 1:
    print("YES")
    exit()
if n_kind == 2 and len(S) == 2:
    print("YES")
    exit()
if n_kind == 2 and len(S) > 2:
    print("NO")
    exit()
if n_kind == 3:
    if mx - mn >= 2:
        print("NO")
    else:
        print("YES")


# Example run
# Input:
u7\fXDkP
# Output:
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  print("YES")
  exit()
a = s[0]
if len(s)==2:
  if s[0]==1 and s[1]==1:
    print("YES")
    exit()
  else:
    print("NO")
    exit()
for i in s:
  if a==i or a==i+1:
    continue
  else:
    print('NO')
else:
  print("YES")

# Example run
# Input:
-3.9241875011539224e+133
# Output:
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
S=input()
l=len(S)
a=0
b=0
c=0
if l%2==0:
    for i in range(l):
        if S[i]=='a':
            a+=1
        elif S[i]=='b':
            b+=1
        else:
            c+=1
            if a%2==0 and b%2==0 and c%2==0:
                print('Yes')
            else:
                print('No')
else:
    for i in range(l):
        if S[i]=='a':
            a+=1
        elif S[i]=='b':
            b+=1
        else:
            c+=1
            if a%2==0 and b%2==0 and c%2==1:
                print('Yes')
            elif a%2==0 and b%2==1 and c%2==0:
                print('Yes')
            elif a%2==1 and b%2==0 and c%2==0:
                print('Yes')
            else:
                print('No')

# Example run
# Input:
zXv9
# Output:
No
Yes
No
Yes
from collections import Counter


S = input()
C = Counter(S)
print(C)
vs = sorted(list(C.values()))
if len(vs) == 1:
    print("YES") if vs[0] == 1 else print("NO")
elif len(vs) == 2:
    print("YES") if vs[0] == vs[1] and vs[0] == 1 else print("NO")
else:
    print("YES") if vs[2] - 1 <= vs[0] and vs[2] - 1 <= vs[1] else print("NO")


# Example run
# Input:
|Au
# Output:
Counter({'|': 1, 'A': 1, 'u': 1})
YES
from collections import*
c=Counter(input())
x=[c["a"],c["b"],c["c"]]
y=min(x)
z=[i-y for i in x]
if set(z)=={0} or set(z)=={0,1}:
    print("YES")
else:
    print("NO")

# Example run
# Input:
5{T0%
# Output:
YES
s = input()
a_cnt = s.count("a")
b_cnt = s.count("b")
c_cnt = s.count("c")
cnt = len(s)
if max(a_cnt, b_cnt, c_cnt) - min(a_cnt, b_cnt, c_cnt) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
QX~6]@
# Output:
YES
S = list(input())

C = []
C.append(S.count('a'))
C.append(S.count('b'))
C.append(S.count('c'))

C = sorted(C)

if C[0] == C[1] == C[2]:
    ans = 'YES'
elif C[0] + 1 == C[1] == C[2]:
    ans = 'YES'
elif C[0] == C[1] == C[2] - 1:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)


# Example run
# Input:
_7k
# Output:
YES
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
  print("NO")
  exit()
if k == 2:
  if len(s) == 2:
    print("YES")
  else:
    print("NO")
  exit()
minabc = sorted([a, b, c])[0]
a = max(0, a - minabc)
b = max(0, b - minabc)
c = max(0, c - minabc)
# print(a, b, c, k)
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
  print("YES")
  exit()
if k == 2:
  if a + b + c == 2:
    print("YES")
  else:
    print("NO")

# Example run
# Input:
lx&:Sr(
# Output:
s = input()
x = len(s)
a = s.count('a')
b = s.count('b')
c = s.count('c')

if x % 3 == 0:
  if a == b == c:
    print('YES')
  else:
    print('NO')
elif x % 3 == 1:
  if a == b + 1 == c + 1 or b == a + 1 == c + 1 or c == a + 1 == b + 1:
    print('YES')
  else:
    print('NO')
else:
  if a == b == c + 1 or b == c == a + 1 or c == a == b + 1:
    print('YES')
  else:
    print('NO')

# Example run
# Input:
5Jq^v\dJ*
# Output:
YES
from collections import Counter
s = input()

#同じ文字を2文字以上離せばよい,acba,abcabなど
#abcabcab,各文字の絶対値の差が1以下であることが必要
if len(s)==1:
    print('YES');exit()
if len(s)==2 and len(set(s))==1:
    print('NO');exit()
if len(s)==3 and len(set(s))<=2:
    print('NO');exit()

s_li = Counter(s).values()
if max(s_li)-min(s_li)<=1 and len(set(s))==3:
    print('YES')
else:
    print('NO')

# Example run
# Input:
<w]}
# Output:
NO
from collections import Counter

s=Counter(input())
b,m=max(s.values()),min(s.values())
kind = len(s.keys())
if kind==3:
    if b-m<=1: print("YES")
    else: print("NO")
elif kind==2:
    if b==1 and m==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

# Example run
# Input:
6.213785916161096e-121
# Output:
NO
from collections import Counter
c = Counter(list(input()))
if len(c) == 2:
  if all(v == 1 for v in c.values()):
    print('YES')
  else:
    print('NO')
else:
  if max(c.values()) >= min(c.values()) + 2:
    print('NO')
  else:
    print('YES')

# Example run
# Input:
y8r+|E
# Output:
YES
S=input()
a=0
b=0
c=0

for i in range(len(S)):
    if S[i]=="a":
        a+=1
    if S[i]=="b":
        b+=1
    if S[i]=="c":
        c+=1

if a==b and a==c or a==b and a==c+1 or a==b and a==c-1 or b==c and c==a+1 or b==c and b==a-1 or c==a and a==b+1 or c==a and a==b-1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
R&e8YVK$
# Output:
YES
s = input()
char_set = set()

for c in s:
    char_set.add(c)

if len(char_set) % 2 == 0:
    ans = 'NO'
else:
    ans = 'YES'

print(ans)


# Example run
# Input:
Lk(&
# Output:
NO
from collections import Counter
s = dict(Counter(input()))
a = [x for x in s.values()]
ans = "NO"
if len(a) == 1 and a[0] == 1: ans = "YES"
elif len(a) == 3 and (a[0] == a[1] >= a[2] or a[0] > a[1] == a[2]): ans = "YES"
print(ans)

# Example run
# Input:
kmQ3mGQ\v
# Output:
NO
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")



# Example run
# Input:
e3zvshd]
# Output:
NO
s = list(input())

a = b = c = 0
for i in s:
    if i == "a":
        a += 1
    elif i == "b":
        b += 1
    else:
        c += 1

if a*b*c == 0 and a+b+c > 2:
    print("NO")
elif max(a,b,c)-min(a,b,c) >= 2:
    print("NO")
else:
    print("YES")





# Example run
# Input:
-1
# Output:
NO
import collections
S = input()
v = sorted(collections.Counter(S).values())

if len(S) == 1:
    print('YES')
    exit()

if len(S) == 2:
    if S[0] != S[1]:
        print('YES')
        exit()
    else:
        print('NO')
        exit()

if len(v) <= 2 or v[2]-v[1] > 1 or v[2]-v[0] > 1:
    print('NO')
else:
    print('YES')


# Example run
# Input:
-S-PKsh$
# Output:
YES
S = input()
C = [S.count('a'),S.count('b'),S.count('c')]
if len(S) == 1:
  print('YES')
elif len(set(S)) == 1 or max(C)-min(C) > 1:
  print('NO')
else:
  print('YES')

# Example run
# Input:
o`u,NtQ5E
# Output:
YES
import collections

S = input()

N = 3
L = (list(collections.Counter(S).values()) + [0] * N)[:N]
min_L = min(L)
L = map(lambda l: l - min_L <= 1, L) # 差が1以下か
print('YES' if all(L) else 'NO')

# Example run
# Input:
NxW
# Output:
YES
s = input()

l = list(s)
k = len(set(l))

f = 0
if k <= 2 :
    if len(s) <= k:
        f = 1
else:
    a = [s.count("a"), s.count("b"), s.count("c")]
    if max(a) - min(a) <= 1:
        f = 1
        
if f:
    print("YES")
else:
    print("NO")

# Example run
# Input:
uKc^L(
# Output:
YES
S = input().strip()
if len(S)==1:
    print("YES")
elif len(S)==2:
    if S[0]!=S[1]:
        print("YES")
    else:
        print("NO")
elif len(S)==3:
    if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[0]:
        print("YES")
    else:
        print("NO")
else:
    C = {"a":0,"b":0,"c":0}
    for i in range(len(S)):
        C[S[i]] += 1
    if len(S)%3==0:
        if C["a"]==C["b"]==C["c"]:
            print("YES")
        else:
            print("NO")
    else:
        if max(C["a"],C["b"],C["c"])==len(S)//3+1 and min(C["a"],C["b"],C["c"])==len(S)//3:
            print("YES")
        else:
            print("NO")
        

# Example run
# Input:
]0=
# Output:
YES
# cf17-finalB - Palindrome-phobia
from collections import Counter


def main():
    S = input().rstrip()
    C = Counter(S).values()
    flg = (len(C) == 3 and max(C) - min(C) <= 1) or (len(C) == 2 and sum(C) == 2)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

# Example run
# Input:
ZrP7lM
# Output:
NO
s = list(map(str,input()))
from collections import Counter
l = Counter(s)
abc = [l["a"],l["b"],l["c"]]
mx = max(abc)
mi = min(abc)
md = sum(abc)-mx-mi
if mx-mi == 1 or mx-mi == 0:
  print("YES")
else:
  print("NO")

# Example run
# Input:
Tdv
# Output:
YES
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    s = list(input())
    result = [s.count("a"), s.count("b"), s.count("c")]
    tmp = min(result)
    for i in result:
        if i - tmp > 1:
            print("No")
            exit(0)

    print("Yes")


if __name__ == '__main__':
    main()


# Example run
# Input:
@&1\)C[
# Output:
Yes
def main():
    S = list(input())
    a = S.count('a')
    b = S.count('b')
    c = S.count('c')
    if a == b and b == c:
        print('YES')
    elif abs(a - b) > 1 or abs(b - c) > 1 or abs(a-c) > 1:
        print('NO')
    else:
        print('YES')

if __name__ == '__main__':
    main()

# Example run
# Input:
aG]'ME=|
# Output:
YES
import collections
A = input()
Ac = collections.Counter(A)
maxA = max(Ac.values())
print('YES' if maxA<=(len(A)+2)/3 else 'NO') 


# Example run
# Input:
JxHz
# Output:
YES