A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this point, at least one 'a' and one 'b' exist in the string.

B now gives this string to C and he appends some number of letters 'c' to the end of the string. However, since C is a good friend of A and B, the number of letters 'c' he appends is equal to the number of 'a' or to the number of 'b' in the string. It is also possible that the number of letters 'c' equals both to the number of letters 'a' and to the number of letters 'b' at the same time.

You have a string in your hands, and you want to check if it is possible to obtain the string in this way or not. If it is possible to obtain the string, print "YES", otherwise print "NO" (without the quotes).


-----Input-----

The first and only line consists of a string $S$ ($ 1 \le |S| \le 5\,000 $). It is guaranteed that the string will only consist of the lowercase English letters 'a', 'b', 'c'.


-----Output-----

Print "YES" or "NO", according to the condition.


-----Examples-----
Input
aaabccc

Output
YES

Input
bbacc

Output
NO

Input
aabc

Output
YES



-----Note-----

Consider first example: the number of 'c' is equal to the number of 'a'. 

Consider second example: although the number of 'c' is equal to the number of the 'b', the order is not correct.

Consider third example: the number of 'c' is equal to the number of 'b'.

Difficulty: competition

Starter code:

Solutions:
'''input
aabc
'''

def list_input():
    return list(map(int,input().split()))
def map_input():
    return map(int,input().split())
def map_string():
    return input().split()
    
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
ans = "YES"
if(a == 0 or b == 0): ans = "NO"
if(c != a and c != b): ans = "NO"
for i in range(len(s)-1):
	if(s[i] > s[i+1]): ans = "NO"
print(ans)	

a = input()
if a.count('a') == a.find('b') and a.count('a') + a.count('b') == a.find('c') and (a.count('a') == a.count('c') or a.count('b') == a.count('c')) and a.count('a') * a.count('b'):
    print("YES")
else:
    print("NO")


string = input()

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

ad = False
bd = False
cd = False

ans = True

ba = string.count('ba')
cb = string.count('cb')
ca = string.count('ca')


if (a > 0) and (b > 0) and ((a == c) or (b == c)) and (ba == 0) and (cb == 0) and (ca == 0):
    print('YES')
else:
    print('NO')
    


'''input
bbcc
'''
def ii():
	return input()
def arr():
	return list(map(int,ii().split()))

s = ii()
a = 0
b = 0
c = 0

for ch in s:	
	if ch =='a':
		a+=1
		if b!=0 or c!=0:
			print("NO")
			return
	elif ch =='b':
		b = b+1
		if c!=0:
			print("NO")
			return
	else:
		c = c + 1

if a!=0 and b!=0 and c!=0:
	if c == a or c== b:
		print("YES")
		return

print("NO")


x=input()
last=''
for i in x:
 if i==last: continue
 elif last=='' and i=='a':
  last='a'
 elif last=='a' and i=='b':
  last='b'
 elif last=='b' and i=='c':
  last='c'
 else:
  print('NO')
  return

if x.count('a') and x.count('b') and (x.count('a')==x.count('c') or x.count('b')==x.count('c')):
 print('YES')
else: print('NO')

s = input()
i = 0
while i < len(s):
    if s[i] == 'a':i+=1
    else:break
while i < len(s):
    if s[i] == 'b':i+=1
    else:break
while i < len(s):
    if s[i] == 'c':i+=1
    else:break
ac =s.count('a')
bc = s.count('b')
cc = s.count('c')
if ac > 0 and bc > 0 and cc > 0 and (cc in[ac,bc]) and (i == len(s)):print('YES')
else:print('NO')


import re

pattern = r'^a+b+c+$'

s = input()

if re.match(pattern,s):
	l = len(s)
	pos_b = s.index('b')
	pos_c = s.index('c')
	len_c = l-pos_c
	len_b = l-len_c-pos_b
	len_a = l-len_c-len_b
	print (('NO','YES')[len_c in (len_b,len_a)])

else:
	print ('NO')

import re

def sv():
	S = input()
	if not re.match(r'^a+b+c+$', S):
		return False
	chrs = {'a':0,'b':0,'c':0}
	for c in S:
		chrs[c] += 1
	return chrs['c'] == chrs['a'] or chrs['c'] == chrs['b']

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


s=input()

a=0
b=0
c=0

if (''.join(sorted(s))==s):
    for i in s:
        if i=='a':
            a+=1
        elif i=='b':
            b+=1
        elif i=='c':
            c+=1
    #print(a,b,c)
    if a>0 and b>0 and (c==a or c==b):
        print("YES")
    else:
        print("NO")

else:
    print("NO")


import fileinput
import sys

class MyInput(object) :
    def __init__(self,default_file=None) :
        self.fh = sys.stdin
        if (len(sys.argv) >= 2) : self.fh = open(sys.argv[1])
        elif default_file is not None : self.fh = open(default_file)
    def getintline(self,n=-1) : 
        ans = tuple(int(x) for x in self.fh.readline().rstrip().split())
        if n > 0 and len(ans) != n : raise Exception('Expected %d ints but got %d in MyInput.getintline'%(n,len(ans)))
        return ans
    def getfloatline(self,n=-1) :
        ans = tuple(float(x) for x in self.fh.readline().rstrip().split())
        if n > 0 and len(ans) != n : raise Exception('Expected %d floats but got %d in MyInput.getfloatline'%(n,len(ans)))
        return ans
    def getstringline(self,n=-1) :
        ans = tuple(self.fh.readline().rstrip().split())
        if n > 0 and len(ans) != n : raise Exception('Expected %d strings but got %d in MyInput.getstringline'%(n,len(ans)))
        return ans
    def getbinline(self,n=-1) :
        ans = tuple(int(x,2) for x in self.fh.readline().rstrip().split())
        if n > 0 and len(ans) != n : raise Exception('Expected %d bins but got %d in MyInput.getbinline'%(n,len(ans)))
        return ans

def compress(s) :
    s2 = [s[0]]
    for c in s :
        if c != s2[-1] : s2.append(c)
    return "".join(s2)

def __starting_point():
    myin = MyInput()
    (s,) = myin.getstringline(1)
    ## Make sure there are a's followed by b's followed by c's
    ## Make sure the count of cs either equals count of as or count of bs
    s1 = compress(s)
    ans = "NO"
    if s1 == 'abc' and ( s.count('c') == s.count('a') or s.count('c') == s.count('b') ) : ans = "YES"
    print(ans)


__starting_point()

def main():
    s = input()
    cnt_a = 0
    cnt_b = 0
    cnt_c = 0
    for c in s:
        if c == 'a':
            if cnt_b != 0 or cnt_c != 0:
                print('NO')
                return
            cnt_a += 1
        if c == 'b':
            if cnt_c != 0:
                print('NO')
                return
            cnt_b += 1
        if c == 'c':
            cnt_c += 1
    if cnt_a != 0 and cnt_b != 0 and (cnt_c == cnt_a or cnt_c == cnt_b):
        print('YES')
        return
    print('NO')


main()

s = input()
a = 0
b = 0
c = 0
i = 0
while i < len(s) and s[i] == 'a':
    a+=1
    i+=1
while i < len(s) and s[i] == 'b':
    b+=1
    i+=1
while i < len(s) and s[i] == 'c' :
    c+=1
    i+=1
if i == len(s) and  (a == c or b == c) and a*b!=0:
    print("YES")
else:print("NO")

s = str(input())
a = 0
b = 0
c = 0
stage = 0
for i in range(len(s)):
    if s[i] == 'a' and stage <= 1:
        a += 1
        stage = 1
    elif s[i] == 'b' and stage > 0 and stage < 3:
        b += 1
        stage = 2
    elif s[i] == 'c' and stage > 1 and stage < 4:
        c += 1
        stage = 3
    else:
        stage = 100
        break
if stage == 3 and a > 0 and b > 0 and (c == a or c == b):
    print('YES')
else:
    print('NO')




s = input()
flag = 0
ans = 1
aa = s.count("a")
bb = s.count("b")
cc = s.count("c")
if min(aa,bb) == 0 or (bb != cc and aa != cc):
    print("NO")
else:
    for i in s:
        if flag == 0:
            if i == "b":
                flag = 1
                continue
            if i != "a":
                ans = 0
                break
        elif flag == 1:
            if i == "c":
                flag = 2
                continue
            if i != "b":
                ans = 0
                break
        else:
            if i != "c":
                ans = 0
                break
    if ans == 1:
        print("YES")
    else:
        print("NO")


s = input()
i = 0
n = len(s)
while i < n-1:
   if ord(s[i]) <= ord(s[i+1]):
      i += 1
   else:
      break
if i == n-1 and s.count('a') > 0 and s.count('b') > 0 and (s.count('c') == s.count('a') or s.count('c') == s.count('b')):
   print('YES')
else:
   print('NO')


s=input()
L=[0,0,0]
ss=s.lstrip("a")
L[0]=len(s)-len(ss)
sss=ss.lstrip("b")
L[1]=len(ss)-len(sss)
ssss=sss.lstrip("c")
L[2]=len(sss)-len(ssss)
if ssss!="":
    print("NO")
elif 0 in L:
    print("NO")
else:
    if L[2] in (L[0],L[1]):
        print("YES")
    else:
        print("NO")


state = 1

s = input()


if ((s.count('a') == 0) or (s.count('b') == 0) or ((s.count('c') != s.count('a') and (s.count('c') != s.count('b'))))):
    print('NO')
    return

for el in s:
    if el == 'b':
        state = max(state, 2)
    if el == 'c':
        state = max(state, 3)
    if state != 1 and el == 'a':
        print("NO")
        return
    if state != 2 and el == 'b':
        print("NO")
        return
    if state != 3 and el == 'c':
        print("NO")
        return
        
print("YES")

from collections import Counter

s = list(input().strip())
if s != sorted(s):
    print('NO')
    return
if set(s) != set(['a', 'b', 'c']):
    print('NO')
    return

x = Counter(s)
if x['c'] == x['a'] or x['c'] == x['b']:
    print('YES')
else:
    print('NO')


import sys

s = input()
a = 0
b = 0
c = 0
state = 'a'
for i in s:
    if state == 'a':
        if i == 'a':
            a += 1
        elif i == 'b':
            b += 1
            state = 'b'
        elif i == 'c':
            state = 'c'
            c += 1
        else:
            print("NO")
            return
    elif state == 'b':
        if i == 'a':
            print("NO")
            return
        elif i == 'b':
            b += 1
        elif i == 'c':
            state = 'c'
            c += 1
        else:
            print("NO")
            return
    elif state == 'c':
        if i == 'a':
            print("NO")
            return
        elif i == 'b':
            print("NO")
            return
        elif i == 'c':
            state = 'c'
            c += 1
        else:
            print("NO")
            return
if a == 0 or b == 0 or (c != a and c != b):
    print("NO")
else:
    print("YES")


from collections import Counter as Cnt

s = input()

cur = 0
while cur < len(s) and s[cur] == 'a':
	cur += 1

if cur == len(s):
	print('NO')
	return

while cur < len(s) and s[cur] == 'b':
	cur += 1

while cur < len(s) and s[cur] == 'c':
	cur += 1

if cur != len(s):
	print('NO')
	return

c = Cnt(s)
if c['a'] > 0 and c['b'] > 0 and (c['c'] == c['a'] or c['c'] == c['b']):
	print('YES')
else:
	print('NO')

# -*- coding: UTF-8 -*-

s = input()
status = ['a', 'b', 'c']
count = [0, 0, 0]
p = 0
flag = True

for c in s:
    while p < 3 and c != status[p]:
        p += 1
    if p >= 3:
        flag = False
        break
    count[p] += 1

if count[0] == 0 or count[1] == 0 or count[2] == 0:
    flag = False
if count[0] != count[2] and count[1] != count[2]:
    flag = False
if flag:
    print('YES')
else:
    print('NO')


s = input()
a = [0] * 3
k = 0
ok = True
for i in s:
    c = ord(i) - ord('a')
    if c == k:
        a[k] += 1
    elif c == k + 1:
        k += 1
        a[k] += 1
    else:
        ok = False
        break
if a[0] == 0 or a[1] == 0 or (a[0] != a[2] and a[1] != a[2]):
    ok = False
if ok: print('YES')
else: print('NO')