Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
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:
gz<
# Output:
YES
from collections import Counter
s = Counter(input())
ss = list(s.values())
ss.sort()
if len(ss) != 3:
  print('NO')
elif ss[2] - ss[0] <= 1:
  print('YES')
else:
  print('NO')

# Example run
# Input:
Ju.
# Output:
YES
import collections

def ok(s):
    if len(s) == 1:
        return True
    if len(s) == 2:
        return s[0] != s[1]
    
    c = collections.Counter(s)
    return len(c) == 3

s = input()
if ok(s):
    print('YES')
else:
    print('NO')

# Example run
# Input:
-`2,MZ0JC
# Output:
NO
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:
    print('YES')
else:
    print('NO')

# Example run
# Input:
Batc
# Output:
NO
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  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:
nan
# Output:
YES
from collections import Counter
s = input()
s_counter = Counter(s)
s = [0]*3
s[0] = s_counter["a"]
s[1] = s_counter["b"]
s[2] = s_counter["c"]
if max(s)-min(s) >= 2:
    print("NO")
else:
    print("YES")

# Example run
# Input:
3vp2<jugY
# Output:
YES
# B - Palindrome-phobia
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=si()
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('YES')
    elif m==3:
        print('YES')

# Example run
# Input:
0}}x#m
# Output:
s = list(input())
a, b, c = s.count("a"), s.count("b"), s.count("c")
if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1:
    print("NO")
else:
    print("YES")

# Example run
# Input:
(b.S43br
# 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:
cUc&W
# Output:
No
import collections
S = input()
A = collections.Counter(S)
a = A["a"]
b = A["b"]
c = A["c"]
if max(abs(a-b),abs(b-c),abs(c-a)) > 1:
    print("NO")
else:
    print("YES")

# Example run
# Input:
pi35
# 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])
  # print(t)
  if t[2][1]-t[0][1]>=2:
    return 'NO'
  return 'YES'

# main()
print(main())


# Example run
# Input:
-2.6410304451301443e-73
# Output:
YES
def main():
  s = input()
  ac = s.count('a')
  bc = s.count('b')
  cc = s.count('c')
  if abs(ac-bc) <= 1 and abs(bc-cc) <= 1 and abs(ac-cc) <= 1:
    print('YES')
  else:
    print('NO')
  
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

# Example run
# Input:
:|ekDd-
# Output:
YES
import collections
S = input()
c = collections.Counter(S)
if abs(c['a'] - c['b']) <= 1 and abs(c['a'] - c['c']) <= 1 and abs(c['b'] - c['c']) <= 1:
    print('YES')
else:
    print('NO')


# Example run
# Input:
|SM9
# 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:
-9.461662797304065e-61
# Output:
NO
S=input()
a,b,c=0,0,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
m=min(a,b,c)
a,b,c=a-m,b-m,c-m
#print(a,b,c)

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

# Example run
# Input:
W{jTm~%@y
# Output:
YES
from collections import Counter
S = tuple(input())
c = Counter(S)
if not c['a']:
  c['a'] = 0
if not c['b']:
  c['b'] = 0
if not c['c']:
  c['c'] = 0
if max(c.values()) - min(c.values()) < 2:
  print('YES')
else:
  print('NO')

# Example run
# Input:
V2bBsP
# Output:
YES
S = input()
temp = ["a", "b", "c"]
abc = [S.count(x) for x in temp]
abc.sort(reverse=True)
print(abc)
if abc.count(0) > 0:
    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:
:q|Hq
# Output:
[0, 0, 0]
No
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')

n = len(s)
if n%3 == 0:
    if a == b and b == c:
        print('YES')
    else:
        print('NO') 

elif n%3 == 1:
    v = [a,b,c]
    v.sort()
    if v[0] == v[1] and v[1]+1 == v[2]:
        print('YES')
    else:
        print('NO')


elif n%3 == 2:
    v = [a,b,c]
    v.sort()
    if v[0]+1 == v[1] and v[1] == v[2]:
        print('YES')
    else:
        print('NO')

# Example run
# Input:
*'x-S-PK
# 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])[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:
vs8
# Output:
YES
import collections
s = list(input())
n = len(s)

flg = True

for i in range(n-1):
  if len(set(s[i:i+2]))==1:
    flg = False

for i in range(n-2):
  tmp = s[i:i+3]
  if tmp == tmp[::-1]:
    flg = False

print('YES' if flg else 'NO')


# Example run
# Input:
-3.5480388464000616e-121
# Output:
NO
S=input()
l=[S.count('a'),S.count('b'),S.count('c')]
f=max(l)-min(l)<=1
print('YES' if f else 'NO')

# Example run
# Input:
{YV;0a2wr
# Output:
YES
S = input()
if len(S) == 1:
    print('YES')
    exit()
if len(set(list(S))) == 1 or len(set(list(S))) == 2:
    print('NO')
    exit()
cnt = [S.count('a'),S.count('b'),S.count('c')]
if max(cnt)-min(cnt) <= 1 and sum(cnt) != 3:
    print('YES')
else:
    print('NO')

# Example run
# Input:
1^}e^'y?H
# Output:
YES
s = str(input())
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
#print(d)

if len(s) == 2 and len(d) == 2:
    print('YES')
    exit()

if len(d) > 2:
    if max(d.values())-min(d.values()) <= 1:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


# Example run
# Input:
6.89925385376605e-83
# Output:
NO
S = input()
from collections import Counter
ctr = Counter(S)

mx = max(ctr.values())
mn = min(ctr.values())
if len(ctr) < 3: mn = 0
if abs(mx-mn) < 2:
    print('YES')
else:
    print('NO')

# Example run
# Input:
J`WyD
# Output:
YES
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(s) == 1:
    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:
~9)b
# Output:
YES
from collections import defaultdict


def main():
    # 同じ文字を2つつなげると回文になるので、最低限隣り合う文字が全部異なる必要がある。
    # また、abaのように、2つ先で一致してしまってもこれも回文になるのでNG。
    # となると結局「abcabc...」みたいに巡回する形の文字列しか回文回避の方法はない。
    # こういう巡回する形の文字列を作るには、a,b,cの数の最大と最小の差が1以内であればOK。
    S = input()
    counter = defaultdict(int)
    for s in S:
        counter[s] += 1
    counts = [counter[s] for s in "abc"]
    if max(counts) - min(counts) <= 1:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

# Example run
# Input:
XAM#&R
# Output:
YES
s = input()
cnt = [s.count("a"),s.count("b"), s.count("c")]
if sum(cnt) == 1: print("YES")
elif len(set(cnt)) == 1 or max(cnt) - min(cnt) > 1: print("NO")
else: print("YES")

# Example run
# Input:
F:w3bt
# Output:
YES
s = list(input())
t = set(s)
if(len(t) == 1):
    if(len(s) == 1):
        print('YES')
    else:
        print('NO')
elif(len(t) == 2):
    if(len(s) == 2):
        print('YES')
    else:
        print('NO')
else:
    n = [0,0,0]
    for i in s:
        if(i == 'a'):n[0] +=1
        if(i == 'b'):n[1] +=1
        if(i == 'c'):n[2] +=1
    n.sort()
    n[1] -= n[0]
    n[2] -= n[0]
    n[0] -= n[0]
    if(n[1] <= 1 and n[2] <= 1):
        print('YES')
    else:
        print('NO')




# Example run
# Input:
!ZrP7l
# Output:
YES
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:
DK5
# 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:
  if a + b + c == 1:
    print("YES")
  else:
    print("NO")
  exit()
if k == 2:
  if a + b + c == 2:
    print("YES")
  else:
    print("NO")

# Example run
# Input:
g#.
# Output:
# cf17-finalB - Palindrome-phobia
from collections import Counter


def main():
    S = input().rstrip()
    C = Counter(S).values()
    flg = [len(C) == 1 and sum(C) == 1]  # e.g. "a"
    flg += [len(C) == 2 and sum(C) == 2]  # "ab"
    flg += [len(C) == 3 and max(C) - min(C) <= 1]  # "abcab"
    print("YES" if any(flg) else "NO")


if __name__ == "__main__":
    main()

# Example run
# Input:
Batc
# Output:
NO
"""
2文字 or 3文字だけ？
aa
bb
cc
二文字並ばないように並び替える
"""
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 >= 2:
        print("NO")
    else:
        print("YES")


# Example run
# Input:
~!8
# Output:
YES
S = input()

a = S.count('a')
b = S.count('b')
c = S.count('c')
n = len(S)//3
k = len(S)-n*3
if a >= n and b >= n and c >= n:
  if k == 2 and max(a-n,b-n,c-n) == 2:
    print('NO')
  else:
    print('YES')
else:
  print('NO')


# Example run
# Input:
70800
# Output:
NO
S = input()
S = sorted(S)

A = S.count("a")
B = S.count("b")
C = S.count("c")

member = [A, B, C]

if S == "ab" or S == "ac" or S == "bc":
    print("YES")
elif max(member) - min(member) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
},,Y
# Output:
YES
def myAnswer(S:str)-> str:
   N = len(S) // 2
   dic = {}
   for s in S:
      if(s in dic.keys()):
         dic[s]+=1
      else:
         dic[s] = 1
   ans = max(dic.values())
   return "YES" if(ans <= N) else "NO"

def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()

# Example run
# Input:
nan
# Output:
NO
S = input()
l = []
l.append(S.count("a"))
l.append(S.count("b"))
l.append(S.count("c"))
if max(l) - min(l) < 1:
  print("NO")
else:
  print("YES")

# Example run
# Input:
}x#m#d=C
# Output:
NO
# 解説
from collections import Counter

s = input()

ctr = Counter(s)
ctr.update({c: 0 for c in 'abc'})

cond = max(ctr.values()) - min(ctr.values()) <= 1

print('YES' if cond else 'NO')

# 偶数文字の回文には2文字の回文が含まれる
# 奇数文字の回文には3文字の回文が含まれる
# 2/3文字の回文が含まれないようにできればよい
# 同じ文字同士の間隔を2文字以上離せばよい
# abcabc...しかない
# 3文字のブロックと余りのブロックで各文字の出現数の差は1以下の必要がある


# Example run
# Input:
>#:pjLk(&
# 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:
^Y8b
# 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 mx - rest == 1 and mn == 0:
    print("NO") 
else:
    if mx - rest >= 2:
        print("NO")
    else:
        print("YES")


# Example run
# Input:
U({C
# Output:
YES
S = input()

D = {}

for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

V = sorted(D.values())

if len(D) == 1 :
    ans = "NO"
elif len(D) == 2 :
    if V[0] == V[1] :
        ans = "YES"
    else :
        ans = "NO"
else :
    if V[2] - V[0] <= 1 :
        ans = "YES"
    else :
        ans = "NO"

print(ans)

# Example run
# Input:
-7.164778762692787e+149
# Output:
YES
from collections import Counter
S = input()
c = list(Counter(S).values())

if len(c) != 3:
    ans = "YES" if len(S) == len(c) else "NO"
else:
    flag = True
    for i in range(len(c) - 1):
        for j in range(i+1, len(c)):
            if abs(c[i] - c[j]) > 1:
                flag = False
    ans = "YES" if flag else "NO"

print(ans)


# Example run
# Input:
]?*3:[_
# Output:
YES
S = input()
from collections import Counter
C = Counter(S)
if len(C.keys()) == 1:
    if sum(C.values()) >= 2:
        print("NO")
    else:
        print("YES")
elif len(C.keys()) == 2:
    if sum(C.values()) < 3:
        print("YES")
    else:
        print("NO")
else:
    a = C["a"]
    b = C["b"]
    c = C["c"]
    if (abs(a-b)<=1) and (abs(c-b)<=1) and (abs(a-c)<=1):
        print("YES")
    else:
        print("No")


# Example run
# Input:
cJI:x5
# Output:
YES
S = input()
cnt_a = 0
cnt_b = 0
cnt_c = 0
for s in S:
    if s == 'a':
        cnt_a += 1
    elif s == 'b':
        cnt_b += 1
    else:
        cnt_c += 1
if abs(cnt_a - cnt_b) <= 1 and abs(cnt_b - cnt_c) <= 1 and abs(cnt_c - cnt_a):
    print('YES')
else:
    print('NO')


# Example run
# Input:
G9$uz\!r(
# Output:
NO
s=input()
a,b,c=s.count("a"),s.count("b"),s.count("c")
ma=max([a,b,c])
mi=min([a,b,c])
print("YES" if ma-mi<=1 else "NO")

# Example run
# Input:
xOg\
# Output:
YES
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

S = Counter(s)
a = S["a"]
b = S["b"]
c = S["c"]

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

# Example run
# Input:
M?Gg\`^
# Output:
YES
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  print("NO")
  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:
4.5760195987025465e+42
# Output:
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
S = input()
cnt = [S.count(x) for x in 'abc']
cnt.sort()
if (cnt[0]+cnt[1]-2 == 2*cnt[2] or 2*cnt[2] == cnt[0]+cnt[1]) and cnt[0] == cnt[1]:
    print('YES')
else:
    print('NO')

# Example run
# Input:
HdbMcJI:x
# Output:
NO
S=input()
k=S.count('a')
l=S.count('b')
m=S.count('c')

if abs(k-l)<=1 and abs(l-m)<=1 and abs(m-k)<=1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
5{T0%
# Output:
YES
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if len(set(list(s)))==1 and len(s)>1:
  print('NO')
elif len(set(list(s)))==2 and len(s)>2:
  print('NO')
elif abs(a-b)<=1 or abs(b-c)<=1 or abs(c-a)<=1:
  print('YES')
else:
  print('NO')

# Example run
# Input:
"O?Wixhv
# 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 n_kind == 1:
    if len(S) == 1:
        print("YES")
        exit()
    else:
        print("NO")
        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:
6ej=k^S/8
# Output:
S = input()
if len(S) == 1:
    print('YES')
    exit()
if len(set(list(S))) == 1 or len(set(list(S))) == 2:
    print('NO')
    exit()
cnt = [S.count('a'),S.count('b'),S.count('c')]
if max(cnt)-min(cnt) <= 1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
Lk(&
# Output:
YES
import collections
import copy

s = list(map(str,input()))
c = copy.copy(s)
c = set(c)
ans = [0]*3
tmp = collections.Counter(s)
ans[0] = tmp["a"]
ans[1] = tmp["b"]
ans[2] = tmp["c"]

if len(c) == 1:
    print("YES")
else:
    tmp = min(ans)
    if abs(ans[0])-tmp <= 1 and abs(ans[1])-tmp <= 1 and abs(ans[2])-tmp <= 1:
        print("YES")
    else:
        print("NO") 

# Example run
# Input:
UU]r$Y
# Output:
YES
S = input()
from collections import Counter
C = Counter(S)
if len(C.keys()) == 1:
    if sum(C.values()) >= 2:
        print("NO")
    else:
        print("YES")
elif len(C.keys()) == 2:
    if sum(C.values()) < 3:
        print("YES")
    else:
        print("NO")
else:
    print("YES")


# Example run
# Input:
-1351531223
# Output:
YES
import sys
from collections import Counter
S = list(input())
N = len(S)
S = Counter(S)
if len(S) == 1:
    if N == 1:
        print("YES")
        sys.exit()
    else:
        print("NO")
        sys.exit()
if len(S) == 2:
    if N == 2:
        print("YES")
        sys.exit()
    else:
        print("NO")
        sys.exit()

a = S["a"]
b = S["b"]
c = S["c"]
M = max(a, b, c)
m = min(a, b, c)

if (M-m) <= 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
Zz}.
# Output:
YES
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')

ans = ''
if a == 0 and b == 0 and c >= 2:
  ans = 'NO'
elif a == 0 and b == 0 and c == 1:
  ans = 'YES'
elif  a == 0 and b >= 2 and c == 0:
  ans = 'NO'
elif a == 0 and b == 1 and c == 0:
  ans = 'YES'
elif a >= 2 and b == 0 and c == 0:
  ans = 'NO'
elif a == 1 and b == 0 and c == 0:
  ans = 'YES'
elif a == 0 and (b >= 2 or c >= 2):
  ans = 'NO'
elif a == 0 and b == 1 and c == 1:
  ans = 'YES'
elif (a >= 2 or c >= 2) and b == 0:
  ans = 'NO'
elif a == 1 and b == 0 and c == 1:
  ans = 'YES'
elif (a >= 2 or b >= 2) and c == 0:
  ans = 'NO'
elif a == 1 and b == 1 and c == 0:
  ans = 'YES'
elif a + b <= c:
  ans = 'NO'
elif b + c <= a:
  ans = 'NO'
elif c + a <= b:
  ans = 'NO'
else:
  ans = 'YES'
print(ans)

# Example run
# Input:
Batc
# Output:
YES
from collections import Counter
X= input()
S = Counter(X)
if len(S.keys()) == 3:
    if max(S.values()) - min(S.values()) >= 2:
        print("NO")
    else:
        print("YES")
if len(S.keys()) == 2:
    if max(S.values()) - min(S.values()) >= 2:
        print("NO")
    else:
        print("YES")
if len(S.keys()) == 1:
    if len(X) == 1:
        print("YES")
    else:
        print("NO")

# Example run
# Input:
-2
# Output:
YES
def solve():
    s = list(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:
        return 'YES'

    return 'NO'

print(solve())


# Example run
# Input:
9'r
# Output:
YES
S = input() 
  
a_count = S.count('a')
b_count = S.count('b')
c_count = S.count('c')

if max(a_count,b_count,c_count)-min(a_count,b_count,c_count)<=1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
Ju.
# 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:
    aa = cm[0][1]
    bb = cm[1][1]
    if aa-bb<2:
        print('YES')
    else:
        print('NO')

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

# Example run
# Input:
-55649
# Output:
from collections import Counter
c = Counter(list(input()))
if len(c) == 1:
  if list(c.values())[0] == 1:
    print('YES')
  else:
    print('NO')
elif 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:
^tx
# Output:
YES
from collections import Counter
s = input()
d = Counter(s)
n = len(s)
if n%3==0:
  if all(v==n//3 for v in d.values()):
    print('YES')
  else:
    print('NO')
else:
  if all(v==n//3 or v==n//3+1 for v in d.values()):
    print('YES')
  else:
    print('NO')

# Example run
# Input:
-itX>w
# Output:
NO
# -*- coding: utf-8 -*-
from collections import Counter

def pri(x):
    if x == 1:
        return print("YES")
    else:
        return print("NO")

S = list(input())

S.sort()
c = list(Counter(S).values())
if len(c) <= 2:
    for _ in range(3-len(c)):
        c.append(0)
c.sort(reverse = True)

if c[0] >= c[1] - 1:
    if c[2] >= c[0] - 1:
        pri(1)
    else:
        pri(0)
else:
    pri(0)

# Example run
# Input:
-7698469
# Output:
YES
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:
e3zvshd]
# 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:
        print("NO")
        exit()

print("YES")

# Example run
# Input:
0
# Output:
YES
from collections import Counter


S = input()
C = Counter(S)
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] else print("NO")
else:
    print("YES") if (vs[2] - 1 <= vs[0] and vs[2] - 1 <= vs[1]) or vs[2] - 1 <= vs[
        0
    ] + vs[1] <= vs[2] else print("NO")


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

# Example run
# Input:
'ZXT~.yFv
# Output:
NO
s=input()
a=s.count("a")
b=s.count("b")
c=s.count("c")
p=[a,b,c]
p=sorted(p,reverse=True)
print("NO" if p[0]-p[2]>=2 else "YES")
  

# Example run
# Input:
e3zvshd]
# Output:
YES
from collections import Counter
s = list(input())

t = len(s)
count = Counter(s)
for i in count.values():
  if t < 2*i:
    print("NO")
    break
else:
  print("YES")

# Example run
# Input:
d-3D,
# Output:
YES