Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
from collections import Counter
def main():
    s = input()
    if len(s) == 1:
        print('Yes')
        return
    if len(s) == 2:
        if len(set(s)) == 1: print('No')
        else: print('Yes')
        return
    cc = Counter(s)
    if all([cc[cha] >= len(s)//3 for cha in list(set(s))]):
        print('Yes')
    else:
        print('No')
    return

if __name__ == '__main__':
    main()
    

# Example run
# Input:
9U)c6@(1b
# Output:
No
from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(S) % 3 == 0:
  if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')
elif len(S) % 3 == 1:
  if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')
else:
  if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')

# Example run
# Input:
V.z0
# 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 and abs(b-c) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
'_n
# Output:
YES
s=input()
l=list(s)
import collections
c=collections.Counter(l)
m=c.most_common()
ll=[]
for i,j in m:
    ll.append(j)
if len(m)<=2:
    if len(m)==1 and max(ll)==1:
        print("YES")
    elif len(m)==2 and max(ll)==1:
        print("YES")
    else:
        print("NO")
else:
    if max(ll)-min(ll)<=1:
        print("YES")
    elif sum(ll)-max(ll)>=max(ll)-1 and min(ll)>=max(ll)//2-1:
        print("YES")
    else:
        print("NO")


# Example run
# Input:
-436822
# 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 max(c.values()) == min(c.values()):
    print("YES")
elif len(S) == 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
c7P~Hdvo
# Output:
NO
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')

L = [a,b,c]
print('YES' if max(L)-min(L) < 2 else 'NO')


# Example run
# Input:
t84
# Output:
YES
import collections
import sys

s=input()
S=collections.Counter(x for x in s)

a=S['a']
b=S['b']
c=S['c']

L=set([x for x in s])

if len(s)==1:
  print('YES')
  sys.exit()
elif len(s)==2:
  if len(L)==2:
    print('YES')
  else:
    print('NO')
  sys.exit()
elif len(s)==3:
  if len(L)==3:
    print('YES')
  else:
    print('NO')
  sys.exit()

if a==b and b==c:
  print('YES')
elif a==b:
  if min(b,c)+1==max(b,c):
    print('YES')
  else:
    print('NO')
else:
  if min(a,b)+1==max(a,b):
    if a==c or b==c:
      print('YES')
    else:
      print('NO')
  else:
    print('NO')

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

ac = s.count('a')
bc = s.count('b')
cc = s.count('c')

if max([ac, bc, cc])-min([ac, bc, cc])<=1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
-`2,MZ0JC
# Output:
YES
from collections import Counter
s = input()
# ２文字以上の回文でない→ abcabc...の形のみ？

cs = Counter(s)
cnts = [val for itr, val in cs.items()]
if (max(cnts) - min(cnts) <= 1 and len(cnts) == 3) or (max(cnts) == min(cnts) == 1 and len(cnts) <= 2):
  print("YES")
else:
  print("NO")

# Example run
# Input:
W'fMa)B=
# Output:
NO
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 1 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:
~!8
# Output:
YES
from collections import defaultdict
s = input()
cnt = defaultdict(int)
for i in range(len(s)):
    cnt[s[i]] += 1
mean = len(s) // 3
for t in ["a", "b", "c"]:
    if cnt[t] != mean and cnt[t] != mean + 1:
        print("NO")
        exit()

print("YES")

# Example run
# Input:
-4
# Output:
YES
def solve():
    s = list(input())
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    hoge = [a, b, c]
    for i in range(2):
        if abs(hoge[i] - hoge[i+1]) > 1 or abs(hoge[0] - hoge[2]) > 1:
            print("NO")
            break
    else:
        print("YES")
    return 0

if __name__ == "__main__":
    solve()


# Example run
# Input:
q\y`^
# Output:
YES
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  s=list(S())
  t=summarize_list(s)

  if len(s)==1:
    return 'YES'
  if len(s)==2:
    if len(t)==2:
      return 'YES'
    return 'NO'
  if len(t)==2:
    return 'NO'

  t=sorted(t,key=lambda x:x[1])
  if t[0][1]-t[2][1]>=2:
    return 'NO'
  return 'YES'

# main()
print(main())


# Example run
# Input:
6.689431243522799e+72
# Output:
YES
s=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")

# Example run
# Input:
)jy
# Output:
YES
s=input()
import collections
p=collections.Counter(s)
#print(p[max(p)])
if len(p)==3:
    if p[max(p,key=p.get)]-p[min(p,key=p.get)]<2:
        print("YES")
    else:
        print("NO")
if len(p)==2:
    if p[max(p,key=p.get)]>1:
        print("NO")
    else:
        print("YES")
if len(p)==1:
    if p[max(p,key=p.get)]==1:
        print("YES")
    else:
        print("NO")

# Example run
# Input:
-12
# Output:
YES
s = str(input())
L = [s.count('a'), s.count('b'), s.count('c')]
if max(L) - min(L) <= 1:
    print('YES')
else:
    print('NO')


# Example run
# Input:
|Au
# Output:
YES
from collections import Counter
S = input()
c = list(Counter(S).values())

ans = "YES"
if len(c) != 3:
    ans = "NO"
else:
    c.sort()
    if c[2] - c[0] > 1 or c[2] - c[0] > 1:
        ans = "NO"
print(ans)


# Example run
# Input:
YQoc
# Output:
NO
# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b

s = input()
a = b = c = 0
for i in range(len(s)):
    if s[i] == 'a':
        a += 1
    elif s[i] == 'b':
        b += 1
    else:
        c += 1
if abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:
    print('YES')
else:
    print('NO')
print(a, b, c)

# Example run
# Input:
Lk(&
# Output:
NO
0 0 4
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,"d"]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]

if len(dic.values())==1:
  if len(S)==1:
    print("YES")
  else:
    print("NO")
  exit(0)
    
elif len(dic.values())==2:
  if len(S)==2:
    print("YES")
  else:
    print("NO")
  exit(0)
if sum(dic.values()) - smax[0]>= smax[0]:
  if smax[0] - min(dic.values()) <= 1:
    print("YES")
    exit(0)
    
print("NO")


# Example run
# Input:
2.760461747404768e+76
# Output:
NO
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

from collections import Counter

s = input()
C = Counter(s)

a = C["a"]
b = C["b"]
c = C["c"]

li = [a,b,c]
li.sort()

if li[0]+1 >= li[2]:
    print("YES")
else:
    print("NO")

# Example run
# Input:
kU){S
# Output:
YES
from collections import Counter
work = list(Counter(input()).values())
a = work[0]
b = work[1] if len(work)>1 else 0
c = work[2] if len(work)>2 else 0
result = "YES"
if ((a > b + 1 and a > c + 1) or c == 0) and len(work) > 1:
    result = "NO"
print(result)

# Example run
# Input:
-1893070
# Output:
YES
import sys
from collections import  Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    S = input()
    count = Counter(S)
    count['a'] += 0
    count['b'] += 0
    count['c'] += 0
    if max(count.values()) - min(count.values()) <= 1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


# Example run
# Input:
V47LA9
# Output:
YES
import collections
S=input()
a=collections.Counter(S)
answer=0
N=len(S)
for val in a.values():
    if val >=int(N/2):
        answer=1
        break
if answer==0:
    print('YES')
else:
    print('NO')


# Example run
# Input:
-364887703
# Output:
YES
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:
_wWCpN
# Output:
NO
from collections import Counter

s = str(input())

d = Counter(s)
l = [0] * 3
k = 0
for i, j in d.items():
    l[k] = j
    k += 1
Palindrome = False
for i in range(3):
    if abs(l[i-1] - l[i]) > 1:
        Palindrome = True

if Palindrome:
    print('NO')
else:
    print('YES')

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

num_a = num_b = num_c = 0

for st in s:
    if st == "a":
        num_a += 1
    elif st == "b":
        num_b += 1
    elif st == "c":
        num_c += 1

if max(num_a, num_b, num_c) - min(num_a, num_b, num_c) <= 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
rZz}
# Output:
YES
S = [s for s in str(input())]
d = len(S) // 3
from collections import Counter
cntr = sorted(list(Counter(S).values()))
if len(S) == 1:
  print('YES')
elif cntr == [1,1]:
  print('YES')
elif cntr == [d,d,d] or cntr == [d,d,d+1] or cntr == [d,d+1,d+1]:
  print('YES')
else:
  print('NO')

# Example run
# Input:
=.[pS
# Output:
NO
line = input()
size = len(line)
a = line.count('a')
b = line.count('b')
c = size - a - b
MIN = min(min(a, b), c)
a -= MIN
b -= MIN
c -= MIN
if a > 1 or b > 1 or c > 1:
	print('NO')
else:
	print('YES')

# Example run
# Input:
tA{
# Output:
NO
from collections import Counter
S=Counter(list(input())).most_common()
if len(S)==1:
    if S[0][1]!=1:
        print("NO")
    else:
        print("YES")
elif len(S)==2:
    if S[0][1]+S[1][1]>=3:
        print("NO")
    else:
        print("YES")
else:
    if S[0][1]>S[2][1]+1 or S[1][1]>S[2][1]+1 :
        print("NO")
    else:
        print("YES")


# Example run
# Input:
!9,=^6
# Output:
YES
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,"d"]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]
    
if sum(dic.values()) - smax[0]> smax[0]:
  if smax[0] - min(dic.values()) <= 1:
    print("YES")
    exit(0)

print("NO")


# Example run
# Input:
-1.4104808525968941e-25
# Output:
NO
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 - rest >= 1:
        print("NO")
    else:
        print("YES")


# Example run
# Input:
>x#!w6b>
# Output:
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 max(c.values()) == min(c.values()):
    print("YES")
else:
    print("NO")


# Example run
# Input:
&/AcoBt
# Output:
NO
s=input()
l=list(s)
import collections
c=collections.Counter(l)
m=c.most_common()
ll=[]
for i,j in m:
    ll.append(j)
if len(m)<=2:
    if len(m)==1 and max(ll)==1:
        print("YES")
    elif len(m)==2 and max(ll)==1:
        print("YES")
    else:
        print("NO")
else:
    if max(ll)-min(ll)<=1:
        print("YES")
    else:
        print("NO")


# Example run
# Input:
-58867430
# Output:
YES
S = input()
a = S.count("a")
b = S.count("b")
c = S.count("c")
if a == b == c:
    print("YES")
elif a == b == c+1:
    print("YES")
elif a == b+1 == c+1:
    print("YES")
else:
    print("No")

# Example run
# Input:
q\y`^
# Output:
YES
S=input();n=[S.count(x)for x in"abc"];print("YNEOS"[max(n)-min(n)>1::2])

# Example run
# Input:
YspWIDts3
# Output:
YES
s = list(str(input()))
if len(s) == 1:
    print("YES")
    exit()
# 1文字と2文字と3文字で場合分けしてみる
jud = len(set(s))
jud_s = list(set(s))

if jud == 1:
    print("NO")
elif jud == 2:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    if count_0 == count_1:
        print("YES")
    else:
        print("NO")


else:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    count_2 = s.count(jud_s[2])
    if count_0 * 2 == count_1 == count_2 or count_1 * 2 == count_0 == count_2 or count_2 * 2 == count_0 == count_1:
        max_c = max(count_1, count_0, count_2)
        print("NO")
            
    else:
        print("YES")

# Example run
# Input:
M]m;+CP)
# Output:
YES
from collections import Counter
s = input()
n = len(s)
count = dict(Counter(s))
flag = False

if n ==1:
    flag = True
elif n <= 3:
    if max(count.values())!=2:
        flag = True
elif n==4:
    if max(count.values())<=2:
        flag = True
else:
    if "a" in count:
        if "b" in count:
            if "c" in count:
                if count["a"]==count["b"] or count["b"]==count["c"] or count["c"]==count["a"]:
                    dev = max(count.values())-min(count.values())
                    if dev <= 1:
                        flag = True
            
            
print('YES' if flag==True else 'NO')

# Example run
# Input:
false
# Output:
NO
s=input()

a=s.count('a')
b=s.count('b')
c=s.count('c')
#print(a,b,c)

if max([a,b,c])-min([a,b,c])>=2:
    print('NO')
else:
    print('YES')

# Example run
# Input:
My>_*s
# 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:
  if len(s) >= 2:
    print("NO")
  else:
    print("YES")
  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)
if a <= 1 and b <= 1 and c <= 1:
  print("YES")
else:
  print("NO")


# Example run
# Input:
!(4<8u=^A
# 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:
    print('YES')
else:
    print('NO')

# Example run
# Input:
,=^
# Output:
YES
# B - Palindrome-phobia
from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: 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')

# Example run
# Input:
s?jyi97
# Output:
S = input()
cnt = [S.count(x) for x in 'abc']
if max(cnt)-min(cnt) < 2:
    print('YES')
else:
    print('NO')

# Example run
# Input:
R!dTK>W{j
# Output:
YES
s=input();print('YNEOS'[max(L:=[s.count(x)for x in 'abc'])-min(L)>1::2])

# Example run
# Input:
xWAS`~
# Output:
YES
# cf17-finalB - Palindrome-phobia
from collections import Counter


def main():
    S = input().rstrip()
    C = Counter(S).values()
    flg = len(C) == 3 or (len(C) == 2 and sum(C) % 2 == 0)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

# Example run
# Input:
'VhS
# Output:
NO
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()


# Example run
# Input:
sP_vD
# Output:
YES
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(cnt) == 1:
    if len(s) == 1:
        print('YES')
    else:
        print('NO')
    # print('YES')
    exit()
if len(cnt) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
    exit()

if cnt[0][1] > cnt[-1][1] + 1:
    print('NO')
else:
    print('YES')


# Example run
# Input:
|Au
# Output:
YES
import collections
c=collections.Counter("abc"+input()).values()
print("YES" if max(c) - min(c) <= 1 else "NO")


# Example run
# Input:
,=^
# Output:
YES
s = input()
n = len(s)

dic = {}
for i in range(n):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

if len(dic) == 1:
    if n == 1:
        print('YES')
    else:
        print('NO')
elif len(dic) == 2:
    maxi = max(dic.values())
    mini = min(dic.values())
    if maxi == mini:
        print('YES')
    else:
        print('NO')
else:
    maxi = max(dic.values())
    mini = min(dic.values())
    if maxi - mini <= 1:
        print('YES')
    else:
        print('NO')

# Example run
# Input:
-2.905149077324127e-48
# Output:
NO
from collections import Counter

S = input()
C = Counter(S)

if len(C) == 3:
    c = min(C.values())
else:
    c = 0

for cc in C.values():
    if not (cc == c or cc == c + 1):
        print("NO")
        exit()

print("YES")


# Example run
# Input:
p2<j
# Output:
YES
import collections

s = input()
sc = collections.Counter(s).most_common()
if len(sc) < 3:
    sc.append((0, 0))
if sc[0][1] - sc[-1][1] < 2:
    print("YES")
else:
    print("NO")

# Example run
# Input:
-18231
# Output:
YES
from collections import Counter
S = input()
work = list(Counter(S).values())
a = work[0]
b = work[1] if len(work)>1 else 0
c = work[2] if len(work)>2 else 0
result = "YES"
if (a > b + 1 and a > c + 1) or c == 0:
    result = "NO"
print(result)

# Example run
# Input:
21181
# Output:
YES
# coding: utf-8
from collections import Counter
S = input()
cnts = Counter(S)
cv = cnts.values()
top = max(cv)
others = sum(cv) - top
if top > others:
    print("NO")
else:
    print("YES")

# Example run
# Input:
`(R.~jR@
# Output:
YES
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==2 and m==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

# Example run
# Input:
62545106
# Output:
NO
from collections import Counter

S = list(input())
c = Counter(S)

A = c.get("a", 0)
B = c.get("b", 0)
C = c.get("c", 0)

if max(A, B, C) - min(A, B, C) >= 2:
    print("NO")
else:
    print("YES")


# Example run
# Input:
'^}\pKT
# Output:
YES
s=input()

from collections import Counter

c =dict(Counter(s))

if len(c)==1 and c[s[0]]>1:
    print('NO')
    exit(0)

if len(c)==2 and sum(list(c.values()))>2:
    print('NO')
    exit(0)

under_value = 10**18

#出現回数の最小値を探す
for _,Value in c.items():
    under_value = min(under_value,Value)
#それぞれの出現回数から引く（セット分）
for key,_ in c.items():
    c[key]-=under_value
    
f = 0
flg=0
for i,j in c.items():
    if j!=0:
        flg+=1
    f+=j
ans='YES'
if len(c)==3 and f>=3 and flg==2:
    ans='NO'
elif len(c)==3 and f>=2 and flg==1:
    ans='NO'
print(ans)




# Example run
# Input:
nan
# Output:
NO
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if abs(a-b)<2 and abs(a-c)<2 and abs(b-c)<2: print('YES')
else: print('NO')

# Example run
# Input:
1e9_j(4
# Output:
YES
S = input()
cnt = [0] * 3
abc = ["a","b","c"]
for i in range(3):
	cnt[i] = S.count(abc[i])
if abs(cnt[0] - cnt[1]) <= 1 and abs(cnt[1] - cnt[2]) <= 1 and abs(cnt[2] - cnt[0]) <= 1:
	print("YES")
else:
	print("NO")

# Example run
# Input:
t84
# Output:
YES
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def solve(S):
    a = S.count("a")
    b = S.count("b")
    c = S.count("c")
    a, b, c = list(sorted([a, b, c], reverse=True))
    if (a == b == c) or (a - 1 == b == c) or (a - 1 == b - 1 == c):
        return True
    return False


def main():
    S = input()
    print("YES" if solve(S) else "NO")


if __name__ == '__main__':
    main()


# Example run
# Input:
'_n
# Output:
YES
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    s = list(input())
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    hoge = [a, b, c]
    for i in range(2):
        if abs(hoge[i] - hoge[i+1]) > 1 or abs(hoge[0] - hoge[2]) > 1:
            print("NO")
            break
    else:
        print("YES")
    return 0

if __name__ == "__main__":
    solve()


# Example run
# Input:
I0ni+
# Output:
YES
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
  print('YES')
else:
  print('NO')

# Example run
# Input:
:Sr(~_p|D
# Output:
YES
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:
    print('YES')
else:
    print('NO')


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

# Example run
# Input:
-9.614519889959056e+133
# Output:
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
import collections
S = input()
v = sorted(collections.Counter(S).values())

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

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


# Example run
# Input:
GQ\vyk`d
# Output:
YES
from collections import Counter
s = input()
# ２文字以上の回文でない→ abcabc...の形のみ？

cs = Counter(s)
cnts = [val for itr, val in cs.items()]
if max(cnts) - min(cnts) <= 1 and len(cnts) == 3:
  print("YES")
else:
  print("NO")

# Example run
# Input:
-K~
# Output:
YES
S = input()
cnt = [0, 0, 0]
for s in S:
    if s == "a":
        cnt[0] += 1
    elif s == "b":
        cnt[1] += 1
    else:
        cnt[2] += 1
base = len(S) // 3
ans = False
for i in range(3):
    if base <= cnt[i] <= base+1:
        pass
    else:
        break
else:
    ans = True
if ans:
    print("YES")
else:
    print("NO")

# Example run
# Input:
0
# Output:
YES