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: EASY
Tags: Implementation

Starter code:

Solutions:
a = list(input())
b = list(set(a))
b.sort()
c = []
p = 96
for k in range(len(a)):
	if ord(a[k]) < p:
		p = 0
		break
	if a[k] not in c:
		c.append(a[k])
		p += 1
if len(set(a)) <= 2 or p == 0:
	print('NO')
elif b == c and (a.count('a') == a.count('c') or a.count('b') == a.count('c')):
	print('YES')
else:
	print('NO')


s = input()
n = len(s)
c = s.count('c')
a = s.count('a')
b = s.count('b')
if c not in [a, b] or a * b * c == 0:
	print('NO')
elif c == a:
	if s[:a] == a * 'a' and s[n - c:] == c * 'c':
		print('YES')
	else:
		print('NO')
elif c == b:
	if s[a:n - c] == b * 'b' and s[n - c:] == c * 'c':
		print('YES')
	else:
		print('NO')
else:
	print('NO')


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


s = str(input())
aDone = False
bDone = False
nextOK = False
for i in range(0, len(s)):
	if i == len(s) - 1:
		if s[i] == 'c':
			nextOK = True
	if not aDone:
		if s[i] == 'b':
			aDone = True
		elif s[i] == 'c':
			break
	elif aDone and (not bDone):
		if s[i] == 'a':
			break
		elif s[i] == 'c':
			bDone = True
	elif s[i] == 'a' or s[i] == 'b':
		break
if nextOK:
	if (s.count('c') == s.count('a') or s.count('c') == s.count('b')) and min(s.count('a'), s.count('b'), s.count('c')) > 0:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input().strip()
a_count = s.count('a')
b_count = s.count('b')
c_count = s.count('c')
arr = list(s)
arr1 = arr.copy()
arr1.sort()
if a_count > 0 and b_count > 0 and (a_count == c_count or b_count == c_count) and (arr == arr1):
	print('YES')
else:
	print('NO')


from re import findall
s = input()
for i in range(len(s) - 1):
	if s[0] == 'a':
		if ord(s[i + 1]) - ord(s[i]) == 0 or ord(s[i + 1]) - ord(s[i]) == 1:
			continue
		else:
			print('NO')
			break
	else:
		print('NO')
		break
else:
	lst = [len(findall(i, s)) for i in 'abc']
	print('YES' if (lst[2] == lst[0] or lst[2] == lst[1]) and (lst[0] != 0 and lst[1] != 0 and (lst[2] != 0)) else 'NO')


def avail(keremama):
	a = 0
	b = 0
	c = 0
	kaj = str(keremama)
	if kaj.count('ac') == 0 and kaj.count('ca') == 0 and (kaj.count('cb') == 0) and (kaj.count('ba') == 0) and (kaj.count('a') != 0) and (kaj.count('b') != 0) and (kaj.count('c') != 0):
		return 1
	else:
		return 0

def ca(ki):
	kaj = str(ki)
	c = kaj.count('a')
	return c

def cb(ki):
	kaj = str(ki)
	c = kaj.count('b')
	return c

def cc(ki):
	kaj = str(ki)
	c = kaj.count('c')
	return c
inp = input()
if avail(inp) == 1 and cc(inp) == ca(inp):
	print('YES')
elif avail(inp) == 1 and cc(inp) == cb(inp):
	print('YES')
else:
	print('NO')


s = input()
a = 0
while a < len(s) and s[a] == 'a':
	a += 1
if a == 0:
	print('NO')
	exit(0)
b = a
while b < len(s) and s[b] == 'b':
	b += 1
b -= a
if b == 0:
	print('NO')
	exit(0)
c = a + b
if len(s) == c:
	print('NO')
	exit(0)
if len(s) - c == a or len(s) - c == b:
	if set(s[c:]) == set('c'):
		print('YES')
		exit(0)
print('NO')


import re
s = input()
(a, b, c) = (s.count('a'), s.count('b'), s.count('c'))
if re.match('a+b+c+$', s) and (a == c or b == c):
	print('YES')
else:
	print('NO')


from collections import Counter
s = list(input().strip())
if s != sorted(s):
	print('NO')
	exit()
if set(s) != set(['a', 'b', 'c']):
	print('NO')
	exit()
x = Counter(s)
if x['c'] == x['a'] or x['c'] == x['b']:
	print('YES')
else:
	print('NO')


def ii():
	return input()

def arr():
	return 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')
			exit()
	elif ch == 'b':
		b = b + 1
		if c != 0:
			print('NO')
			exit()
	else:
		c = c + 1
if a != 0 and b != 0 and (c != 0):
	if c == a or c == b:
		print('YES')
		exit()
print('NO')


s = input()
a = s.count('a')
b = s.count('b')
print(('NO', 'YES')[a * b and s in ('a' * a + 'b' * b + 'c' * i for i in (a, b))])


string = list(input().strip())
want = sorted(string)
for i in range(len(string)):
	if want[i] != string[i]:
		print('NO')
		quit()
(a, b, c) = (0, 0, 0)
for i in string:
	if i == 'a':
		a += 1
	if i == 'b':
		b += 1
	if i == 'c':
		c += 1
if a > 0 and b > 0:
	if c == a or c == b:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
(ac, bc, cc) = (s.count('a'), s.count('b'), s.count('c'))
print('YES' if ac and bc and (ac * 'a' + bc * 'b' + cc * 'c' == s) and (cc in (ac, bc)) else 'NO')


res = list(input())
res2 = []
res2.append(res[0])
for i in range(1, len(res)):
	if res[i] == res2[-1]:
		pass
	else:
		res2.append(res[i])
if len(res2) != 3:
	print('NO')
	quit()
if 'a' in res and 'b' in res and ('c' in res):
	out = 'YES'
else:
	print('NO')
	quit()
q = ['a', 'b', 'c']
(ai, an) = (res.index('a'), res.count('a'))
(bi, bn) = (res.index('b'), res.count('b'))
(ci, cn) = (res.index('c'), res.count('c'))
maxab = an + bn
if cn == an or cn == bn:
	out = 'YES'
else:
	print('NO')
	quit()
if ai < bi < ci:
	print('YES')
else:
	print('NO')
	quit()


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


s = input()
from collections import Counter
c = Counter(s)
if len(c) == 3 and c['a'] >= 1 and (c['b'] >= 1) and (c['c'] >= 1) and (c['c'] == c['a'] or c['c'] == c['b']) and (''.join(sorted(s)) == s):
	print('YES')
else:
	print('NO')


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')


lst = list(input())
a1 = 0
b1 = 0
c1 = 0
lst2 = []
z = 0
for i in range(len(lst)):
	if lst[i] == 'a':
		a1 += 1
	elif lst[i] == 'b':
		b1 += 1
	else:
		c1 += 1
	if lst[i] not in lst2:
		lst2.append(lst[i])
	if len(lst2) > 0:
		if lst2[-1] != lst[i]:
			z = 1
if len(lst2) == 0:
	z = 1
elif len(lst2) == 3:
	if lst2[0] == 'b' or lst2[0] == 'c':
		z = 1
	elif lst2[1] == 'a' or lst2[1] == 'c':
		z = 1
	elif lst2[2] == 'b' or lst2[2] == 'a':
		z = 1
elif len(lst2) == 2:
	if lst2[0] == 'c' and lst2[1] == 'b':
		z = 1
	elif lst2[0] == 'c' and lst2[1] == 'a':
		z = 1
	elif lst2[0] == 'b' and lst2[1] == 'a':
		z = 1
	elif lst2[0] == 'b' and lst2[1] == 'c':
		z = 1
	elif lst2[0] == 'a' and lst2[1] == 'c':
		z = 1
elif len(lst2) == 1:
	z = 1
if (a1 == c1 or b1 == c1 or (a1 == c1 and b1 == c1)) and z == 0:
	print('YES')
else:
	print('NO')


l = input()
if 'a' in set(l) and 'b' in set(l) and ('c' in set(l)):
	x = l.count('a')
	y = l.count('b')
	z = l.count('c')
	m = 'a' * x + 'b' * y + 'c' * z
	if (z == x or z == y) and m == l and (z != 0) and (x != 0) and (y != 0):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


l = list(input())
a = b = c = 0
done = 0
for i in range(len(l)):
	if l[0] == 'a':
		a += 1
		l.remove('a')
	else:
		break
for j in range(len(l)):
	if l[0] == 'b':
		b += 1
		l.remove('b')
	elif j == 'a':
		done = 1
		break
	else:
		break
for k in range(len(l)):
	if l[0] == 'c':
		c += 1
		l.remove('c')
	else:
		done = 1
		break
if done == 1:
	print('NO')
elif a == 0 or b == 0 or c == 0:
	print('NO')
elif c == a or c == b:
	print('YES')
else:
	print('NO')


def solution():
	string = input()
	(numa, numb, numc) = (0, 0, 0)
	for i in range(len(string)):
		if string[i] == 'a':
			numa += 1
		else:
			break
	for j in range(i, len(string)):
		if string[j] == 'b':
			numb += 1
		elif string[j] == 'a':
			print('NO')
			return
		else:
			break
	for m in range(j, len(string)):
		if string[m] == 'c':
			numc += 1
		elif string[m] == 'a' or string[m] == 'b':
			print('NO')
			return
	if numa == 0 or numb == 0:
		print('NO')
		return
	if numc == numb or numc == numa:
		print('YES')
	else:
		print('NO')
solution()


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')


s = input()
l = len(s)
sta = 0
flag = True
(a, b, c) = (0, 0, 0)
for i in range(l):
	if sta == 0:
		if s[i] == 'a':
			a = a + 1
		elif s[i] == 'b':
			b = b + 1
			sta = 1
		else:
			flag = False
			break
	elif sta == 1:
		if s[i] == 'b':
			b = b + 1
		elif s[i] == 'c':
			c = c + 1
			sta = 2
		else:
			flag = False
			break
	elif s[i] == 'c':
		c = c + 1
	else:
		flag = False
		break
if flag and a > 0 and (b > 0) and (c > 0) and (c == b or c == a):
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline

def solve1(s):
	a = ''
	ans = 1
	for c in s:
		if c not in a:
			a += c
	if a != 'abc':
		ans = 0
	elif s.count('a') != s.count('c') and s.count('b') != s.count('c'):
		ans = 0
	else:
		flag = 0
		for i in range(len(s)):
			if flag == 0:
				if s[i] == 'a':
					pass
				elif s[i] == 'b':
					flag = 1
				else:
					ans = 0
			elif flag == 1:
				if s[i] == 'b':
					pass
				elif s[i] == 'c':
					flag = 2
				else:
					ans = 0
					break
			elif s[i] != 'c':
				ans = 0
				break
	return 'YES' if ans else 'NO'

def solve2(s):
	ans = 1
	a = s.count('a')
	b = s.count('b')
	if a and b and (s == 'a' * a + 'b' * b + 'c' * a or s == 'a' * a + 'b' * b + 'c' * b):
		pass
	else:
		ans = 0
	return 'YES' if ans else 'NO'
s = input()[:-1]
print(solve2(s))


s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a == 0 or b == 0:
	print('No')
	exit(0)
if a * 'a' + b * 'b' + c * 'c' == s and (a == c or b == c):
	print('Yes')
else:
	print('No')


s = input()
slen = len(s)

def solve():
	if s[0] != 'a':
		print('NO')
		return
	a_count = 1
	b_count = 0
	c_count = 0
	i = 1
	while i < slen:
		if s[i] == 'a' and s[i - 1] != 'a':
			print('NO')
			return
		if s[i] == 'b' and s[i - 1] == 'c':
			print('NO')
			return
		if s[i] == 'c' and s[i - 1] == 'a':
			print('NO')
			return
		if s[i] == 'a':
			a_count += 1
		elif s[i] == 'b':
			b_count += 1
		elif s[i] == 'c':
			c_count += 1
		i += 1
	if a_count == 0 or b_count == 0 or c_count == 0:
		print('NO')
		return
	if c_count == a_count or c_count == b_count:
		print('YES')
	else:
		print('NO')
	return
solve()


s = input()
a = b = c = 0
t1 = t2 = t3 = 0
a = s.count('a')
b = s.count('b')
c = s.count('c')
t1 = s.count('ba')
t2 = s.count('ca')
t3 = s.count('cb')
if t1 > 0 or t2 > 0 or t3 > 0:
	print('No')
elif a != 0 and b != 0 and (c == a or c == b):
	print('YES')
else:
	print('NO')


_str = input()
a = b = c = 0
ai = _str.rfind('a')
bi = _str.find('b')
ci = _str.find('c')
for char in _str:
	if char == 'a':
		a += 1
	elif char == 'b':
		b += 1
	elif char == 'c':
		c += 1
if (c == a or c == b) and (ai != -1 and bi != -1 and (ci != -1)) and (_str.rfind('a') < _str.find('b') and _str.rfind('b') < _str.find('c')):
	print('YES')
else:
	print('NO')


def no():
	print('NO')
	quit()
s = input()
(a, b, c) = (0, 0, 0)
for i in s:
	if i == 'a':
		if c + b:
			no()
		else:
			a += 1
	elif i == 'b':
		if c:
			no()
		else:
			b += 1
	else:
		c += 1
if not a * b:
	no()
if not (c == a or c == b):
	no()
print('YES')


s = input()
l = []
checked = True
for i in range(0, len(s)):
	l.append(s[i])
if sorted(l) != l:
	checked = False
n = {}
for letter in list(set(s)):
	n[letter] = l.count(letter)
if n.get('a') == None or n.get('b') == None:
	checked = False
if n.get('c') != n.get('a') and n.get('c') != n.get('b'):
	checked = False
if n.get('c') == None:
	checked = False
if checked:
	print('YES')
else:
	print('NO')


s = input()
(a, b, c) = (0, 0, 0)
(af, bf, cf) = (False, False, False)
res = True
for i in range(len(s)):
	if not res:
		break
	if i == 0:
		if s[i] != 'a':
			res = False
			break
		else:
			a += 1
			af = True
	elif af and bf and cf:
		if s[i] != 'c':
			res = False
			break
		else:
			c += 1
	elif af and bf:
		if s[i] != 'b' and s[i] != 'c':
			res = False
			break
		elif s[i] == 'b':
			b += 1
		elif s[i] == 'c':
			cf = True
			c += 1
	elif af:
		if s[i] != 'a' and s[i] != 'b':
			res = False
			break
		elif s[i] == 'a':
			a += 1
		elif s[i] == 'b':
			b += 1
			bf = True
if res and (a == c and a and c or (b == c and b and c)):
	print('YES')
else:
	print('NO')


inps = input()
countmap = {'a': 0, 'b': 0, 'c': 0}
if inps.count('a') == 0 or inps.count('b') == 0:
	print('NO')
	exit()
if 'ab' in inps and 'bc' in inps and ('ca' not in inps) and ('cb' not in inps) and ('ba' not in inps):
	if inps.count('c') == inps.count('a') or inps.count('c') == inps.count('b'):
		print('YES')
		exit()
print('NO')


s = input()
sl = [i for i in s]
if 'a' not in sl or 'b' not in sl or 'c' not in sl:
	print('NO')
	exit(0)
if sl[0] != 'a' or sl[-1] != 'c':
	print('NO')
	exit(0)
if sl.count('c') != sl.count('a') and sl.count('c') != sl.count('b'):
	print('NO')
	exit(0)
import re
l = [k.start() for k in re.finditer('a', s)]
j = [k.start() for k in re.finditer('b', s)]
h = [k.start() for k in re.finditer('c', s)]
x = l + j + h
y = l + j + h
x.sort()
if x != y:
	print('NO')
else:
	print('YES')


s = input()
s += 'd'
l = []
ans = ''
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1]:
		ans += s[i]
	else:
		ans += s[i]
		l.append(ans)
		ans = ''
if len(l) != 3:
	print('NO')
else:
	a = len(l[0])
	b = len(l[1])
	c = len(l[2])
	if l[0][0] != 'a' or l[1][0] != 'b' or l[2][0] != 'c':
		print('NO')
	elif a == c or b == c:
		print('YES')
	else:
		print('NO')


s = input()
ca = s.count('a')
cb = s.count('b')
cc = s.count('c')
f1 = 0
f2 = 0
if cc != ca and cc != cb:
	print('NO')
	f2 = 1
fa = 0
fb = 1
fc = 1
if f2 == 0:
	for i in range(len(s)):
		if fa == 0 and s[i] != 'a':
			fa = 1
			if s[i] != 'b':
				f1 = 1
				print('NO')
				break
			else:
				fb = 0
		if fa == 1 and s[i] == 'a':
			f1 = 1
			print('NO')
			break
		if fb == 0 and s[i] != 'b':
			if s[i] != 'c':
				f1 = 1
				print('NO')
				break
			else:
				fc = 0
		if fc == 0 and s[i] != 'c':
			f1 = 1
			print('NO')
			break
if f1 == 0 and f2 == 0:
	if cc >= 1 and ca >= 1 and (cb >= 1):
		print('YES')
	else:
		print('NO')


s = input()
if len(set(s)) == 3:
	if 'ba' in s or 'ca' in s or 'cb' in s:
		exit(print('NO'))
	elif s.count('a') == s.count('c') or s.count('b') == s.count('c'):
		exit(print('YES'))
print('NO')


cin = input
s = list(cin())
a = [0] * 3
if len(set(s)) < 3 or s != sorted(s):
	print('NO')
else:
	for c in s:
		a['abc'.index(c)] += 1
	print('YNEOS'[not (a[0] == a[2] or a[1] == a[2])::2])


def getNum(l):
	(num_a, num_b, num_c) = (0, 0, 0)
	for i in l:
		if i == 'a':
			num_a += 1
		elif i == 'b':
			num_b += 1
		elif i == 'c':
			num_c += 1
	return (num_a, num_b, num_c)
s = input()
(num_a, num_b, num_c) = getNum(s)
flag = True
if not ('a' in set(s) and 'b' in set(s)):
	flag = False
if flag and sorted(s) == list(s) and (num_c == num_a or num_c == num_b):
	print('YES')
else:
	print('NO')


import sys
import itertools as it
import math as mt
import collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
s = list(input().strip())
n = len(s)
c = cc.Counter(s)
f = cc.defaultdict(int)
tf = 1
if len(set(s)) < 3:
	print('NO')
else:
	for i in range(n):
		f[s[i]] += 1
		if s[i] == 'a':
			if f['b'] or f['c']:
				tf = 0
				break
		if s[i] == 'b':
			if f['c']:
				tf = 0
				break
	if not tf:
		print('NO')
	elif c['c'] == c['a'] or c['c'] == c['b']:
		print('YES')
	else:
		print('NO')


s = input()
d = {}
t = sorted(s)
flag = False
(d['a'], d['b'], d['c']) = (0, 0, 0)
for i in range(len(s)):
	d[s[i]] += 1
	if s[i] != t[i]:
		flag = True
if d['a'] == 0 or d['b'] == 0 or d['c'] == 0:
	print('NO')
	exit()
if d['a'] != d['c'] and d['b'] != d['c']:
	print('NO')
	exit()
if flag == True:
	print('NO')
else:
	print('YES')


import re
s = input()
m = re.match('^(a+)(b+)(c+)$', s)
if m:
	(a, b, c) = m.groups()
	if len(c) in (len(a), len(b)):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def main():
	s = input()
	ind_b = s.index('b')
	if ind_b == 0 or s[:ind_b] != 'a' * ind_b:
		print('NO')
		return
	ind_c = s.index('c')
	if s[ind_b:ind_c] != 'b' * (ind_c - ind_b):
		print('NO')
		return
	if s[ind_c:] != 'c' * (len(s) - ind_c):
		print('NO')
		return
	if len(s) - ind_c != ind_b and len(s) - ind_c != ind_c - ind_b:
		print('NO')
		return
	print('YES')
try:
	main()
except:
	print('NO')


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


s = input()
ac = bc = cc = 0
for i in range(len(s)):
	if i >= 1:
		if s[i] < s[i - 1]:
			print('NO')
			break
	if s[i] == 'a':
		ac += 1
	elif s[i] == 'b':
		bc += 1
	else:
		cc += 1
else:
	if (ac == cc or bc == cc) and (ac >= 1 and bc >= 1):
		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()
(a0, b0, c0) = (s.find('a'), s.find('b'), s.find('c'))
if -1 in [a0, b0, c0] or b0 < a0 or c0 < a0 or (c0 < b0):
	print('NO')
	exit()
from collections import Counter
(a_s, b_s, c_s) = (Counter(s[a0:b0]), Counter(s[b0:c0]), Counter(s[c0:]))
if len(a_s.keys()) > 1 or len(b_s.keys()) > 1 or len(c_s.keys()) > 1:
	print('NO')
elif c_s['c'] not in [b_s['b'], a_s['a']]:
	print('NO')
else:
	print('YES')


import sys
b1 = 0
b2 = 0
b3 = 0
s = input()
l = 1
for i in range(len(s)):
	if l == 1 and s[i] == 'a':
		b1 += 1
	elif l == 1 and s[i] == 'c':
		l = 3
		b3 += 1
	elif l == 1 and s[i] == 'b':
		b2 += 1
		l = 2
	elif l == 2 and s[i] == 'b':
		b2 += 1
	elif l == 2 and s[i] == 'a':
		print('NO')
		sys.exit()
	elif l == 2 and s[i] == 'c':
		l = 3
		b3 += 1
	elif l == 3 and s[i] == 'c':
		b3 += 1
	elif l == 3 and s[i] == 'a':
		print('NO')
		sys.exit()
	elif l == 3 and s[i] == 'b':
		print('NO')
		sys.exit()
if (b1 == b3 or b2 == b3) and b3 != 0 and (b1 != 0) and (b2 != 0):
	print('YES')
else:
	print('NO')


_ = input()
__ = [len(_) - _[::-1].find('a') - 1, _.find('b'), len(_) - _[::-1].find('b') - 1, _.find('c'), _.count('a'), _.count('b'), _.count('c')]
print('YES' if (__[0] < __[1] and __[2] < __[3]) and (__[6] == __[5] or __[6] == __[4]) else 'NO')


s = input()
a_count = b_count = c_count = 0
bb = s.find('b')
cc = s.find('c')
l = list(s)
a_count = l.count('a')
b_count = l.count('b')
c_count = l.count('c')
l1 = []
if 'a' in l[bb:]:
	print('NO')
elif 'b' in l[cc:]:
	print('NO')
elif a_count == 0 or b_count == 0:
	print('NO')
elif a_count == c_count or b_count == c_count:
	print('YES')
else:
	print('NO')


import sys
s = input()
if s.count('c') == 0 or s.count('a') == 0 or s.count('b') == 0:
	print('NO')
	sys.exit()
for x in range(len(s) - 1):
	if s[x] > s[x + 1]:
		print('NO')
		sys.exit()
if s.count('a') == s.count('c') or s.count('b') == s.count('c'):
	print('YES')
else:
	print('NO')


s = input()
if 'a' in s and 'b' in s and ('c' in s) and (len(set(s)) == 3) and (''.join(sorted(s)) == s) and (s.count('c') in [s.count('a'), s.count('b')]):
	print('YES')
else:
	print('NO')


s = str(input())
a = 0
b = 0
c = 0
flag = False
flag2 = False
for i in s:
	if i == 'a':
		if flag or flag2:
			print('NO')
			exit(0)
		a += 1
	elif i == 'b':
		flag = True
		if flag2:
			print('NO')
			exit(0)
		b += 1
	else:
		flag2 = True
		c += 1
	if a == 0 and (b != 0 or c != 0):
		print('NO')
		exit(0)
	if b == 0 and c != 0:
		print('NO')
		exit(0)
if (a == c or b == c) and a != 0 and (b != 0) and (c != 0):
	print('YES')
else:
	print('NO')


import re
s = input()
m = re.match('a+b+', s)
if m == None:
	print('NO')
	exit()
(l, r) = m.span()
a = s[:r].count('a')
b = s[:r].count('b')
s = s[r:]
if len(set(s)) > 1:
	print('NO')
	exit()
c = s.count('c')
if c == a or c == b:
	print('YES')
else:
	print('NO')


s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a == 0 or b == 0:
	print('No')
	exit(0)
ss = ''
for i in sorted(s):
	ss = ss + i
if ss != s:
	print('No')
	exit(0)
if a == c or b == c:
	print('Yes')
else:
	print('No')


s = input()
t = s[::-1]
a1 = t.find('a')
b1 = t.find('b')
c1 = t.find('c')
a = s.find('a')
b = s.find('b')
c = s.find('c')
ca = s.count('a')
cb = s.count('b')
cc = s.count('c')
if 'a' in s and 'b' in s and ('c' in s) and (a < b < c) and (cc == ca or cc == cb) and (c1 < b1 < a1) and ('cb' not in s) and ('ba' not in s):
	print('YES')
else:
	print('NO')


s = input()
f = 0
ans = 'YES'
if s.count('b') == 0 or s.count('a') == 0:
	ans = 'NO'
elif s.count('a') != s.count('c') and s.count('b') != s.count('c'):
	ans = 'NO'
else:
	for i in range(len(s)):
		if f == 0:
			if s[i] == 'a':
				pass
			elif s[i] == 'b':
				f = 1
			else:
				ans = 'NO'
		elif f == 1:
			if s[i] == 'b':
				pass
			elif s[i] == 'c':
				f = 2
			else:
				ans = 'NO'
				break
		elif s[i] != 'c':
			ans = 'NO'
			break
print(ans)


S = input()
(a, b, c) = (S.count('a'), S.count('b'), S.count('c'))
if not (S[:a] == 'a' * a and S[-c:] == 'c' * c) or a == 0 or b == 0 or (c == 0):
	print('NO')
	exit()
if a == c or b == c:
	print('YES')
	exit()
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')


st = input()
l = len(st)
i = 0
l1 = []
l1.append(0)
l1.append(0)
l1.append(0)
flg = 0
flg1 = 0
for i in range(l):
	if flg == 0 and st[i] == 'a':
		l1[0] = l1[0] + 1
	elif (flg == 1 or flg == 0) and st[i] == 'b':
		if flg == 0:
			flg = 1
		l1[1] = l1[1] + 1
	elif (flg == 2 or flg == 1) and st[i] == 'c':
		if flg == 1:
			flg = 2
		l1[2] = l1[2] + 1
	else:
		flg1 = 1
		break
if flg1 == 1:
	print('NO')
elif (l1[0] == l1[2] or l1[1] == l1[2]) and l1[0] > 0 and (l1[1] > 0):
	print('YES')
else:
	print('NO')


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
s = input()
n = len(s)
flag = 0
for i in range(n):
	ch = ord(s[i]) - ord('a')
	if flag > ch:
		print('NO')
		break
	else:
		flag = ch
else:
	c = s.count('c')
	b = s.count('b')
	a = s.count('a')
	if (c == a or c == b) and c != 0 and (a != 0) and (b != 0):
		print('YES')
	else:
		print('NO')


def soln(strn):
	a_cnt = 0
	b_cnt = 0
	c_cnt = 0
	strn_len = len(strn)
	if strn[0] != 'a':
		return 'NO'
	ind = 0
	while ind < strn_len and strn[ind] == 'a':
		a_cnt += 1
		ind += 1
	if ind < strn_len and strn[ind] != 'b':
		return 'NO'
	while ind < strn_len and strn[ind] == 'b':
		b_cnt += 1
		ind += 1
	if ind < strn_len and strn[ind] != 'c':
		return 'NO'
	while ind < strn_len and strn[ind] == 'c':
		c_cnt += 1
		ind += 1
	if c_cnt != a_cnt and c_cnt != b_cnt:
		return 'NO'
	if b_cnt == 0 or c_cnt == 0:
		return 'NO'
	if ind < strn_len:
		return 'NO'
	return 'YES'
print(soln(input()))


n = input()
sos = 'start'
a = 0
b = 0
c = 0
for i in n:
	if sos == 'start':
		if i == 'a':
			a = a + 1
			sos = 'a'
		elif i == 'b':
			print('NO')
			break
		else:
			print('NO')
			break
	elif sos == 'a':
		if i == 'a':
			a = a + 1
		elif i == 'b':
			sos = 'b'
			b = b + 1
		else:
			print('NO')
			break
	elif sos == 'b':
		if i == 'a':
			print('NO')
			break
		elif i == 'b':
			b = b + 1
		else:
			sos = 'c'
			c = c + 1
	elif i == 'a':
		print('NO')
		break
	elif i == 'b':
		print('NO')
		break
	else:
		c = c + 1
else:
	if (c == a or c == b) and sos == 'c':
		print('YES')
	else:
		print('NO')


from collections import Counter
a = input()
cnt = Counter(a)
if a != ''.join(sorted(a)):
	print('NO')
elif 'ab' not in a or 'bc' not in a:
	print('NO')
elif cnt['a'] != cnt['c'] != cnt['b']:
	print('NO')
else:
	print('YES')


a = input()
q = a
s = []
t = []
r = ''
g = 'a'
f = 0
for i in a:
	if i == 'b' and g == 'a':
		g = 'b'
	if i == 'c' and g == 'b':
		g = 'c'
	if g == 'b' and i == 'a':
		print('NO')
		f = 1
		break
	if g == 'c' and (i == 'b' or i == 'a'):
		print('NO')
		f = 1
		break
if f == 0:
	for i in a:
		if not i in s:
			s.append(i)
		t.append(i)
	if s == ['a', 'b', 'c']:
		v1 = t.count('a')
		v2 = t.count('b')
		v3 = t.count('c')
		if v3 == v2 or v3 == v1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


string = input()

def in_order():
	ans = True
	if string[0] != 'a':
		ans = False
	for i in range(1, len(string)):
		if ans == False:
			break
		if string[i] == 'a' and (string[i - 1] == 'b' or string[i - 1] == 'c'):
			ans = False
		if string[i] == 'b' and string[i - 1] == 'c':
			ans = False
	return ans

def proper_count():
	d = {'a': 0, 'b': 0, 'c': 0}
	for i in string:
		d[i] += 1
	ans = d['c'] == d['a'] or d['c'] == d['b']
	ans = ans and 0 not in d.values()
	return ans
if in_order() and proper_count():
	print('YES')
else:
	print('NO')


s = input()
w = list(s)
w.sort()
w = ''.join(w)
if s != w:
	print('NO')
else:
	a = s.count('a')
	b = s.count('b')
	c = s.count('c')
	if (c == a or c == b) and (a > 0 and b > 0):
		print('YES')
	else:
		print('NO')


s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if len(s) != a + b + c or c not in [a, b] or s[:a] != 'a' * a or (s[-c:] != 'c' * c) or (a == 0) or (b == 0):
	print('NO')
else:
	print('YES')


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


n = input()
d = dict()
for i in 'abc':
	d[i] = 0
c1 = 0
c2 = 0
c3 = 0
for j in n:
	if c1 == 0 and (j == 'b' or j == 'c'):
		print('NO')
		exit()
	if c2 == 1 and j == 'a':
		print('NO')
		exit()
	if j == 'a':
		c1 = 1
	if c2 == 0 and j == 'c':
		print('NO')
		exit()
	if j == 'b':
		c2 = 1
	if j == 'c':
		c3 = 1
	if c3 == 1 and (j == 'a' or j == 'b'):
		print('NO')
		exit()
	d[j] = d[j] + 1
if d['a'] != 0 and d['b'] != 0 and (d['c'] != 0) and (d['a'] == d['c'] or d['b'] == d['c']):
	print('YES')
else:
	print('NO')


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()


c = 0
b = 0
aa = 0
a = input()
fl = 0
if a[0] == 'c':
	c += 1
if a[0] == 'b':
	b += 1
if a[0] == 'a':
	aa += 1
for i in range(1, len(a)):
	if a[i] == 'c':
		c += 1
	if a[i] == 'b':
		b += 1
	if a[i] == 'a':
		aa += 1
	if a[i] < a[i - 1]:
		fl = 1
if aa == 0 or b == 0 or c == 0:
	fl = 1
if aa != c and b != c:
	fl = 1
if fl == 0:
	print('YES', '\n')
else:
	print('NO', '\n')


s = input()
if s != ''.join(sorted(s)):
	print('NO')
	exit()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a > 0 and b > 0 and (c == a or c == b):
	print('YES')
else:
	print('NO')


s = input()
if 'a' in s and 'b' in s and ('c' in s):
	s1 = 'a' * s.count('a') + 'b' * s.count('b') + 'c' * s.count('c')
	if s1 == s and (s.count('c') == s.count('b') or s.count('c') == s.count('a')):
		exit(print('YES'))
	else:
		exit(print('NO'))
else:
	print('NO')


import re
s = input()
regex = re.compile('^a+b+c+$')
if regex.fullmatch(s) is not None and (s.count('c') == s.count('a') or s.count('c') == s.count('b')):
	print('YES')
else:
	print('NO')


import re
r = re.compile('^(a+)(b+)(c+)$')
s = input()
ans = 'NO'
m = re.match(r, s)
if m:
	if len(m.group(1)) == len(m.group(3)) or len(m.group(2)) == len(m.group(3)):
		ans = 'YES'
print(ans)


p = input()
x = p.find('b')
y = p.find('c')
a = p[:x]
b = p[x:y]
c = p[y:]
if a == '' or b == '' or c == '':
	print('NO')
else:
	m = a.count('a')
	n = b.count('b')
	o = c.count('c')
	if m != len(a) or n != len(b) or o != len(c):
		print('NO')
	elif len(c) == len(a) or len(c) == len(b):
		print('YES')
	else:
		print('NO')


import re
s = input()
try:
	print('YES' if re.match('aa*bb*cc*', s).group(0) == s and (s.count('a') == s.count('c') or s.count('b') == s.count('c')) else 'NO')
except:
	print('NO')


def find_left_right(s, n, char):
	i = -1
	j = -1
	for k in range(n):
		if s[k] == char:
			if i == -1:
				i = k
				j = k
			else:
				j = k
	return (i, j)

def main():
	s = input()
	n = len(s)
	a = find_left_right(s, n, 'a')
	b = find_left_right(s, n, 'b')
	c = find_left_right(s, n, 'c')
	flag = False
	if a[0] + a[1] != -2 and b[0] + b[1] != -2 and (c[0] + c[1] != -2):
		if a[1] + 1 == b[0] and b[1] + 1 == c[0]:
			len_a = a[1] - a[0] + 1
			len_b = b[1] - b[0] + 1
			len_c = c[1] - c[0] + 1
			if len_a == len_c or len_b == len_c:
				flag = True
	if not flag:
		print('NO')
	else:
		print('YES')
main()


q = input()
a = q.count('a')
b = q.count('b')
c = q.count('c')
if (q == a * 'a' + 'b' * b + c * 'c') & ((a == c) | (b == c)) & (a > 0) & (b > 0):
	print('YES')
else:
	print('NO')


def check(s):
	if s[0] != 'a':
		return 'NO'
	elif any((s[i + 1] < s[i] for i in range(len(s) - 1))):
		return 'NO'
	elif s.count('a') == len(s):
		return 'NO'
	elif s.count('b') == 0:
		return 'NO'
	elif s.count('b') == s.count('c') or s.count('a') == s.count('c'):
		return 'YES'
	return 'NO'
t = input()
print(check(t))


from collections import *
from functools import reduce
import sys
input = sys.stdin.readline

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())
s = st()
cnt = Counter(s)
if cnt['c'] != cnt['b'] and cnt['c'] != cnt['a'] or not cnt['a'] or (not cnt['b']):
	print('NO')
	exit()
sn = 'a' * cnt['a'] + 'b' * cnt['b'] + 'c' * cnt['c']
print('YES' if s == sn else 'NO')


s = input()
l = list(s)
counta = l.count('a')
countb = l.count('b')
countc = l.count('c')
if counta > 0 and countb > 0 and (countc > 0) and (counta == countc or countb == countc):
	if s.index('c') > s.rindex('a') and s.index('c') > s.rindex('b') and (s.rindex('a') < s.index('b')):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
if s == ''.join(sorted(s)):
	a = s.count('a')
	b = s.count('b')
	c = s.count('c')
	if (a == c or b == c) and ('a' in s and 'b' in s and ('c' in s)):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
cnt1 = 0
cnt2 = 0
cnt3 = 0
y = sorted(s)
j = 0
p = 0
q = 0
r = 0
cnt = 0
for i in y:
	if i != s[j]:
		print('NO')
		cnt = 5
		break
	j += 1
if cnt != 5:
	for i in y:
		if i == 'a':
			cnt1 += 1
			q = 5
		if i == 'b':
			cnt2 += 1
			r = 5
		if i == 'c':
			cnt3 += 1
			p = 5
	if p == 5 and r == 5 and (q == 5):
		if cnt3 == cnt2 or cnt3 == cnt1:
			print('YES')
	if cnt3 != cnt1 and cnt3 != cnt2 or (p == 0 or q == 0 or r == 0):
		print('NO')


a = {'a': 1, 'b': 0, 'c': 0}
s = input()
b = s[0]
if b == 'a':
	pass
else:
	print('NO')
	exit(0)
for i in s[1:]:
	a[i] = a.get(i, 0) + 1
	if b == 'a' and (i == 'a' or i == 'b') or (b == 'b' and (i == 'c' or i == 'b')) or (b == 'c' and i == 'c'):
		b = i
	else:
		print('NO')
		exit(0)
if a['a'] > 0 and a['b'] > 0 and (a['c'] > 0) and (a['a'] == a['c'] or a['b'] == a['c']):
	print('YES')
else:
	print('NO')


s = input()
freq = [0] * 3
ll = {'a': 0, 'b': 1, 'c': 2}
maximo = -1
for i in range(0, len(s)):
	freq[ll[s[i]]] = freq[ll[s[i]]] + 1
	if maximo <= ll[s[i]]:
		maximo = ll[s[i]]
	else:
		print('NO')
		exit()
if freq[0] == 0 or freq[1] == 0:
	print('NO')
elif freq[2] == freq[1] or freq[2] == freq[0]:
	print('YES')
else:
	print('NO')


s = input()
s_reversed = s[::-1]
if s.count('a') != 0 and s.count('b') != 0 and (s.count('c') != 0) and (s[s.index('b'):].count('a') == 0) and (s[s.index('c'):].count('a') == 0) and (s[s.index('c'):].count('b') == 0) and (s.count('c') == s.count('a') or s.count('c') == s.count('b')):
	print('YES')
else:
	print('NO')


s = input()
(a, b, c) = (s.count('a'), s.count('b'), s.count('c'))
if a + b + c == len(s) and (c == a or c == b) and (set(s[:a]) == {'a'}) and (set(s[a:a + b]) == {'b'}):
	print('YES')
else:
	print('NO')


s = str(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 a + b + c != len(s):
	print('NO')
elif (a == c or b == c) and a > 0 and (b > 0):
	print('YES')
else:
	print('NO')


msg = input()
(a, b, c) = (0, 0, 0)
fail = False
if msg[0] == 'a':
	for i in range(len(msg)):
		if msg[i] == 'a':
			if b == 0 and c == 0:
				a += 1
			else:
				fail = True
		elif msg[i] == 'b':
			if c == 0:
				b += 1
			else:
				fail = True
		else:
			c += 1
	if a == 0 or b == 0:
		print('NO')
	elif a == c or b == c:
		if not fail:
			if c != 0 and b != 0:
				print('YES')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


from collections import defaultdict
s = list(input())
t = sorted(s)
flag = True
if s[0] != 'a':
	flag = False
if s != t:
	flag = False
dic = defaultdict(int)
for i in s:
	dic[i] += 1
if dic['a'] == 0 or dic['b'] == 0:
	flag = False
if dic['a'] != dic['c'] and dic['b'] != dic['c']:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


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


s = input().strip()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a > 0 and b > 0 and (c > 0) and (s.rfind('a') < s.find('b')) and (s.rfind('b') < s.find('c')) and (a == c or b == c):
	print('YES')
else:
	print('NO')


import math
s = input()
count_a = s.count('a')
count_b = s.count('b')
count_c = s.count('c')
flag = True
if count_a == 0 or count_b == 0 or count_c == 0:
	print('NO')
	flag = False
if flag:
	for i in range(count_a):
		if s[i] == 'b' or s[i] == 'c':
			print('NO')
			flag = False
			break
if flag:
	for i in range(count_a, count_b + count_a):
		if s[i] == 'a' or s[i] == 'c':
			flag = False
			print('NO')
			break
if flag:
	if count_a == count_c or count_b == count_c:
		print('YES')
	else:
		print('NO')


s = input()
a = 0
b = 0
c = 0
if list(s) == sorted(list(s)):
	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 == c or c == b) and c != 0 and (a != 0) and (b != 0):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys
import os
import math
import re
s = input()
As = [i for (i, ltr) in enumerate(s) if ltr == 'a']
Bs = [i for (i, ltr) in enumerate(s) if ltr == 'b']
Cs = [i for (i, ltr) in enumerate(s) if ltr == 'c']
if len(s) < 3 or len(Bs) == 0 or len(As) == 0 or (len(Cs) == 0):
	print('NO')
	exit(0)
if Bs[0] < As[len(As) - 1] or Cs[0] < Bs[len(Bs) - 1] or Cs[0] < As[len(As) - 1]:
	print('NO')
	exit(0)
if len(Cs) == len(As) or len(Cs) == len(Bs):
	print('YES')
	exit(0)
print('NO')


import re
string = input()
pattern = '^(a)+(b)+(c)+$'
if re.match(pattern, string) and (string.count('c') == string.count('a') or string.count('c') == string.count('b')):
	print('YES')
else:
	print('NO')


s = input()
a = ['ba', 'ca', 'ac', 'cb']
flag = True
for i in a:
	if i in s:
		flag = False
if flag == False:
	print('NO')
else:
	x = s.count('a')
	y = s.count('b')
	z = s.count('c')
	if x > 0 and y > 0:
		if z == x:
			print('YES')
		elif z == y:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from collections import Counter
s = input()
C = Counter(s)
print('YES' if s == ''.join(sorted(s)) and len(C) > 2 and (C['c'] in (C['a'], C['b'])) else 'NO')


s = list(input())
p = []
p = p + s
s.sort()
a = p.count('a')
b = p.count('b')
c = p.count('c')
if 'a' in p and 'b' in p and ('c' in p):
	if (c == a or c == b) and p == s:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def f(s):
	ia = ib = ic = False
	ac = bc = cc = 0
	for c in s:
		if c == 'a':
			ac += 1
			ia = True
			if ib or ic:
				return False
		if c == 'b':
			bc += 1
			ib = True
			if ic:
				return False
		if c == 'c':
			cc += 1
			ic = True
	if cc > 0 and bc > 0 and (ac > 0) and (cc == bc or ac == cc):
		return True
	return False
s = input()
if f(s):
	print('YES')
else:
	print('NO')


s = input()
fa = 0
fb = 0
fc = 0
sl = [i for i in s]
if 'a' in sl:
	fa = 1
if 'b' in sl:
	fb = 1
if fa == 1 and fb == 0 or (fa == 0 and fb == 1):
	print('NO')
	exit(0)
ss = [i for i in s]
ss.sort()
ac = sl.count('a')
bc = sl.count('b')
cc = sl.count('c')
if ss == sl:
	if cc == ac or cc == bc:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
A = int(s.count('a'))
B = int(s.count('b'))
C = int(s.count('c'))
test = 0
if C == A or C == B:
	if A > 0 and B > 0:
		for i in range(A):
			if s[i] != 'a':
				test = 1
				break
		if test == 0:
			for i in range(B):
				if s[A + i] != 'b':
					test = 1
					break
		if test == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


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


string = input()
data = {'a': [], 'b': [], 'c': []}
for i in range(len(string)):
	data[string[i]] += [i]
flag = False
a = data.get('a')
b = data.get('b')
c = data.get('c')
if a and b and c:
	if b[0] > a[-1] and c[0] > b[-1]:
		if len(a) == len(c) or len(b) == len(c):
			flag = True
if flag:
	print('YES')
else:
	print('NO')


s = input()
n = len(s)
ac = 0
ab = 0
acc = 0
i = 0
a1 = s.count('a')
s = s.lstrip('a')
a2 = n - len(s)
n = len(s)
b1 = s.count('b')
s = s.lstrip('b')
b2 = n - len(s)
n = len(s)
c1 = s.count('c')
s = s.lstrip('c')
c2 = n - len(s)
if a1 == a2 and b1 == b2 and (c1 == c2) and (a1 > 0) and (b1 > 0) and (c1 > 0) and (c1 == a1 or c1 == b1):
	print('YES')
else:
	print('NO')


s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
izm = 0
izmlist = []
for i in range(1, len(s)):
	if s[i] != s[i - 1]:
		izm += 1
		izmlist.append(s[i])
if (c == a or c == b) and izm == 2 and (izmlist[0] == 'b') and (izmlist[1] == 'c'):
	print('YES')
else:
	print('NO')


s = input()
l = sorted(s)
print('YES' if (s.count('a') >= 1 and s.count('b') >= 1) and (s.count('c') == s.count('a') or s.count('c') == s.count('b')) and (s == ''.join(l)) else 'NO')


from collections import deque
line = deque(input())
numa = 0
numb = 0
numc = 0
if sorted(line) == list(line):
	while len(line) != 0:
		if line[0] == 'a':
			numa += 1
			line.popleft()
		elif line[0] == 'b':
			numb += 1
			line.popleft()
		elif line[0] == 'c':
			numc += 1
			line.popleft()
		else:
			print('NO')
			break
	if (numa == numc or numb == numc) and (numa != 0 and numb != 0):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
cur = 0
num = dict()
for c in s:
	if c == 'a':
		if cur != 0:
			print('NO')
			exit(0)
	elif c == 'b':
		if cur == 0:
			cur = 1
		if cur != 1:
			print('NO')
			exit(0)
	else:
		if cur == 1:
			cur = 2
		if cur != 2:
			print('NO')
			exit(0)
	if c not in num:
		num[c] = 0
	num[c] += 1
if cur != 2 or 'a' not in num or 'b' not in num or ('c' not in num):
	print('NO')
	exit(0)
if num['c'] == num['a'] or num['c'] == num['b']:
	print('YES')
else:
	print('NO')


s = input()
a = [0]
b = [0, 0, 0]
flag = 'YES'
for i in range(len(s)):
	if s[i] == 'a':
		b[0] += 1
		a.append(1)
	if s[i] == 'b':
		b[1] += 1
		a.append(2)
	if s[i] == 'c':
		b[2] += 1
		a.append(3)
	if a[i] > a[i + 1]:
		flag = 'NO'
		break
if flag == 'NO':
	print(flag)
elif (b[0] == b[2] or b[1] == b[2]) and b[0] != 0 and (b[1] != 0) and (b[2] != 0):
	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')


import collections

def checker(l):
	order = []
	flag = 'a'
	for (index, i) in enumerate(l):
		if flag != i or index == 0:
			if i == 'a':
				order.extend('a')
				flag = 'a'
			elif i == 'b':
				order.extend('b')
				flag = 'b'
			elif i == 'c':
				order.extend('c')
				flag = 'c'
	return order

def getNum(l):
	(num_a, num_b, num_c) = (0, 0, 0)
	for i in l:
		if i == 'a':
			num_a += 1
		elif i == 'b':
			num_b += 1
		elif i == 'c':
			num_c += 1
	return (num_a, num_b, num_c)
s = input()
(num_a, num_b, num_c) = getNum(s)
if checker(list(s)) == ['a', 'b', 'c'] and (num_c == num_a or num_c == num_b):
	print('YES')
else:
	print('NO')


s = input()
a = b = c = 0
last = s[0]
r = s[0]
for i in s:
	if i == 'a':
		a += 1
	elif i == 'b':
		b += 1
	else:
		c += 1
	if last != i:
		r += i
	last = i
if len(r) != 3 or (a != c and b != c) or r != 'abc':
	print('NO')
else:
	print('YES')


def check_number_of_characters(string):
	number_characters_a = string.count('a')
	number_characters_b = string.count('b')
	number_characters_c = string.count('c')
	if number_characters_a == 0 or number_characters_b == 0 or number_characters_c == 0:
		return False
	elif number_characters_c == number_characters_a or number_characters_c == number_characters_b:
		return True

def check_string_order(string):
	string_index = 0
	string_size = len(string)
	for letter in ['a', 'b', 'c']:
		if string[string_index] == letter:
			while string[string_index] == letter:
				string_index += 1
				if string_index == string_size:
					break
		else:
			return False
	if string_index == string_size:
		return True
	else:
		return False
string = input()
if check_number_of_characters(string):
	if check_string_order(string):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import re
(l, r) = (re.findall('(a+|b+|c+)', input()), True)
if [s[0] for s in l] == ['a', 'b', 'c']:
	(a, b, c) = map(len, l)
	r = a != c != b
print(('YES', 'NO')[r])


import sys
import math

def NO():
	print('NO')
	sys.exit()
s = input()
a = 0
b = 0
c = 0
for i in range(len(s)):
	if s[i] == 'a':
		a += 1
		if c > 0 or b > 0:
			NO()
	if s[i] == 'b':
		b += 1
		if c > 0:
			NO()
	if s[i] == 'c':
		c += 1
if a == 0 or b == 0:
	NO()
print('YES' if c == a or c == b else '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()
nrs = {}
nrs['a'] = 0
nrs['b'] = 0
nrs['c'] = 0
curr_state = 0
flag = True
for sym in s:
	nrs[sym] += 1
	if curr_state == 0:
		if sym == 'a':
			continue
		elif sym == 'b':
			curr_state += 1
		elif sym == 'c':
			flag = False
	elif curr_state == 1:
		if sym == 'a':
			flag = False
		elif sym == 'b':
			continue
		elif sym == 'c':
			curr_state += 1
	elif curr_state == 2:
		if sym != 'c':
			flag = False
if nrs['a'] < 1:
	flag = False
if nrs['b'] < 1:
	flag = False
if nrs['c'] != nrs['a'] and nrs['c'] != nrs['b']:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


s = input()
s = list(s)

def lastnum(c):
	if len(s) == 0:
		return 0
	ans = 0
	while s[-1] == c:
		ans += 1
		s.pop()
		if len(s) == 0:
			break
	return ans

def ff():
	l = len(s)
	if s[-1] != 'c':
		return 'NO'
	i = l - 1
	while i >= 0 and s[i] == 'c':
		i -= 1
	if i <= 0:
		return 'NO'
	if s[i] == 'b' and s[i - 1] == 'a':
		return 'YES'
	return 'NO'
c = lastnum('c')
b = lastnum('b')
a = lastnum('a')
l = len(s)
if (c == a or c == b) and l == 0 and (a > 0) and (b > 0):
	print('YES')
else:
	print('NO')


import re

def sv():
	S = input()
	if not re.match('^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')


def print_hi(name):
	print(f'Hi, {name}')

def check_the_string(s):
	if s.find('a') + 1 and s.find('b') and s.find('c') and (s.find('a') < s.find('b') < s.find('c')):
		if 'a' in s[s.find('c'):] or 'b' in s[s.find('c'):]:
			print('NO')
		elif 'a' in s[s.find('b'):]:
			print('NO')
		elif s.count('a') == s.count('c') or s.count('b') == s.count('c'):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
s = input()
check_the_string(s)


s = input()
res = False
if 'a' in s and 'b' in s and ('c' in s):
	a = s.index('a')
	b = s.index('b')
	c = s.index('c')
	if a < b < c and a == 0:
		la = len(s[:b].strip('a'))
		lb = len(s[b:c].strip('b'))
		lc = len(s[c:].strip('c'))
		if la == 0 and lb == 0 and (lc == 0):
			if len(s) - c == b - a or len(s) - c == c - b:
				res = True
if res:
	print('Yes')
else:
	print('NO')


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)


import re
pattern = '^a+b+c+$'
s = list(map(str, input().split()))[0]
if re.match(pattern, s):
	if s.count('c') == s.count('b') or s.count('c') == s.count('a'):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
(a1, a2, b1, b2, c1, c2) = (-1, -1, -1, -1, -1, -1)
(a, b, c) = (0, 0, 0)
for i in range(len(s)):
	if s[i] == 'a':
		a += 1
		if a1 == -1:
			a1 = i
		a2 = i
	if s[i] == 'b':
		b += 1
		if b1 == -1:
			b1 = i
		b2 = i
	if s[i] == 'c':
		c += 1
		if c1 == -1:
			c1 = i
		c2 = i
if a1 == 0 and a2 < b1 and (b2 < c1) and (a == c or b == c):
	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')
	exit()
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')
		exit()
	if state != 2 and el == 'b':
		print('NO')
		exit()
	if state != 3 and el == 'c':
		print('NO')
		exit()
print('YES')


s = input()
(l, flag) = (list(s), True)
l.sort()
if s.find('a') >= 0 and s.find('b') >= 0 and (s.find('c') >= 0):
	pass
else:
	flag = False
if flag:
	for i in range(len(s)):
		if l[i] == s[i]:
			continue
		flag = False
		break
if flag:
	d = {}
	(d['a'], d['b'], d['c']) = (0, 0, 0)
	for i in s:
		d[i] += 1
	if d['a'] == d['c'] or d['b'] == d['c']:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
if s != ''.join(list(sorted(s))):
	print('NO')
elif len([char for char in s if char not in ['a', 'b', 'c']]) > 0:
	print('NO')
else:
	x = len([char for char in s if char == 'a'])
	y = len([char for char in s if char == 'b'])
	z = len([char for char in s if char == 'c'])
	if z in [x, y] and min(x, y) > 0:
		print('YES')
	else:
		print('NO')


from itertools import *
z = ['a', 'b', 'c']
z = list(permutations(z, 2))
k = input()
for i in z:
	k = k.replace(''.join(i), str(i[0] + ' ' + i[1]))
k = k.split()
if len(k) != 3:
	print('NO')
elif 'a' not in k[0] or 'b' not in k[1] or 'c' not in k[2]:
	print('NO')
elif len(k[0]) == len(k[2]) or len(k[1]) == len(k[2]):
	print('YES')
else:
	print('NO')


has_letter = {}
for i in range(0, 3):
	letter = chr(ord('a') + i)
	has_letter[letter] = 0
str_abc = input()
now = 'a'
valid = True
for char in str_abc:
	if char < now:
		valid = False
		break
	now = char
	has_letter[char] += 1
if valid == False or has_letter['a'] * has_letter['b'] * has_letter['c'] == 0 or (has_letter['a'] != has_letter['c'] and has_letter['b'] != has_letter['c']):
	print('NO')
else:
	print('YES')


s = input().strip()
let = 'a'
k = 0
try:
	na = s.index('b')
	nb = s.index('c') - na
	n = len(s)
	nc = n - na - nb
	if na == 0 or nb == 0 or nc not in [na, nb]:
		raise ValueError
	if 'a' * na + 'b' * nb + 'c' * nc != s:
		raise ValueError
	print('YES')
except ValueError:
	print('NO')


l = list(input())
d = sorted(l)
(x, y, z) = (l.count('a'), l.count('b'), l.count('c'))
if l == d:
	if x == 0 or y == 0 or z == 0:
		print('NO')
	elif x == z or y == z:
		print('YES')
	else:
		print('NO')
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')
elif L[2] in (L[0], L[1]):
	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')
			sys.exit()
	elif state == 'b':
		if i == 'a':
			print('NO')
			sys.exit()
		elif i == 'b':
			b += 1
		elif i == 'c':
			state = 'c'
			c += 1
		else:
			print('NO')
			sys.exit()
	elif state == 'c':
		if i == 'a':
			print('NO')
			sys.exit()
		elif i == 'b':
			print('NO')
			sys.exit()
		elif i == 'c':
			state = 'c'
			c += 1
		else:
			print('NO')
			sys.exit()
if a == 0 or b == 0 or (c != a and c != b):
	print('NO')
else:
	print('YES')


import re
inp = input().strip()
if re.match('^a+b+c*$', inp) and inp.count('c') in [inp.count('a'), inp.count('b')]:
	print('YES')
else:
	print('NO')


s = input()
ac = bc = cc = 0
for i in s:
	if i == 'a':
		ac += 1
	elif i == 'b':
		bc += 1
	else:
		cc += 1
if s == 'a' * ac + 'b' * bc + 'c' * cc and (ac == cc or bc == cc) and (ac >= 1 and bc >= 1 and (cc >= 1)):
	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
		elif i != 'c':
			ans = 0
			break
	if ans == 1:
		print('YES')
	else:
		print('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
	if a > 0 and b > 0 and (c == a or c == b):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


u = input()
a = 0
b = 0
c = 0
for i in range(len(u)):
	if u[i] == 'a':
		a += 1
	elif u[i] == 'b':
		b += 1
	else:
		c += 1
if 'a' * a + 'b' * b + 'c' * c == u and a != 0 and (b != 0):
	if c == a or c == b:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


ch = input()
if ch[0] == 'a':
	i = 0
	ca = 0
	while i < len(ch) and ch[i] == 'a':
		ca += 1
		i += 1
	if i == len(ch):
		print('NO')
	elif ch[i] == 'b':
		cb = 0
		while i < len(ch) and ch[i] == 'b':
			cb += 1
			i += 1
		if i == len(ch):
			print('NO')
		else:
			cond = True
			cc = 0
			if ch[i] == 'c':
				for j in range(i, len(ch)):
					if ch[j] == 'c':
						cc += 1
					else:
						cond = False
				if cond:
					if cc == cb or cc == ca:
						print('YES')
					else:
						print('NO')
				else:
					print('NO')
			else:
				print('NO')
	else:
		print('NO')
else:
	print('NO')


l = list(input())
k = sorted(l)
if l != k:
	print('NO')
else:
	a = l.count('a')
	b = l.count('b')
	c = l.count('c')
	if (c == a or c == b) and a > 0 and (b > 0) and (c > 0):
		print('YES')
	else:
		print('NO')


n = input()
v = [str(i) for i in n]
x = [str(i) for i in n]
v.sort()
if x == v:
	a = 0
	b = 0
	c = 0
	for i in x:
		if i == 'a':
			a += 1
		if i == 'b':
			b += 1
		if i == 'c':
			c += 1
	if (c == a or c == b) and (a > 0 and b > 0 and (c > 0)):
		print('YES')
		exit()
print('NO')


import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007
ch = 'abcdefghijklmnopqrstuvwxyz'
lcm = lambda a, b: a * b // gcd(a, b)
setbit = lambda x: bin(x)[2:].count('1')
input = lambda : sys.stdin.readline()

def solve():
	s = sys.stdin.readline().replace('\n', '')
	n = len(s)
	if s.count('a') and s.count('b') and s.count('c'):
		(a, b, c) = (0, 0, 0)
		if s.index('a') < s.index('b') < s.index('c'):
			for i in range(s.index('a'), n):
				if s[i] == 'a':
					a += 1
				else:
					break
			for i in range(s.index('b'), n):
				if s[i] == 'b':
					b += 1
				else:
					break
			for i in range(s.index('c'), n):
				if s[i] == 'c':
					c += 1
				else:
					break
			if a + b + c == n:
				if c == a or c == b:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


import re
s = input()
if not re.match('a+b+c+$', s):
	print('NO')
elif s.count('a') == s.count('c') or s.count('b') == s.count('c'):
	print('YES')
else:
	print('NO')


s = str(input())
now = 'a'
ac = 0
bc = 0
cc = 0
ans = 'Yes'
for i in s:
	if i == 'a' and now == 'a':
		ac += 1
	elif i == 'b' and now != 'c':
		bc += 1
	elif i == 'c':
		cc += 1
	else:
		ans = 'No'
	now = i
if (ac == cc or bc == cc) and ans == 'Yes' and (bc != 0) and (cc != 0) and (ac != 0):
	print(ans)
else:
	print('No')


import re
pattern = '^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')


s = input()
a = 0
b = 0
c = 0
n = len(s)
if s[0] == 'a':
	a += 1
	flag = True
	for i in range(1, n):
		s1 = s[i - 1]
		s2 = s[i]
		if s2 == 'a':
			a += 1
		elif s2 == 'b':
			b += 1
		elif s2 == 'c':
			c += 1
		if s1 == 'a' and s2 == 'a' or (s1 == 'a' and s2 == 'b') or (s1 == 'b' and s2 == 'b') or (s1 == 'b' and s2 == 'c') or (s1 == 'c' and s2 == 'c'):
			continue
		else:
			flag &= False
			break
	if a > 0 and b > 0 and (a == c or b == c):
		flag &= True
	else:
		flag &= False
	if flag:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
count_a = 0
count_b = 0
count_c = 0
flag = True
flagA = False
flagB = False
flagC = False
for i in s:
	if i == 'a':
		if flagC or flagB:
			flag = False
		count_a += 1
		flagA = True
	if i == 'b':
		if flagC:
			flag = False
		count_b += 1
		flagB = True
	if i == 'c':
		count_c += 1
		flagC = True
if count_c != count_a and count_c != count_b:
	flag = False
if count_a == 0 or count_b == 0 or count_c == 0:
	flag = False
if flag == True:
	print('YES')
else:
	print('NO')


import string
import math
s = str(input())
a = list(s)
a.sort()
t = ''.join(a)
if s != t:
	print('NO')
else:
	fa = s.count('a')
	fb = s.count('b')
	fc = s.count('c')
	if fc == 0 or fa == 0 or fb == 0:
		print('NO')
	elif fa == fc:
		print('YES')
	elif fb == fc:
		print('YES')
	else:
		print('NO')


word = input()
a = 0
b = 0
c = 0
stop = False
for i in range(len(word) - 1):
	if ord(word[i]) > ord(word[i + 1]):
		stop = True
		break
	if word[i] == 'a':
		a += 1
	if word[i] == 'b':
		b += 1
	if word[i] == 'c':
		c += 1
if word[len(word) - 1] == 'c':
	c += 1
if not stop and a >= 1 and (b >= 1) and (c >= 1) and (c == a or c == b):
	print('YES')
else:
	print('NO')


s = input()
ac = 0
bc = 0
cc = 0
for i in range(len(s)):
	if s[i] == 'a':
		ac += 1
	elif s[i] == 'b':
		bc += 1
	elif s[i] == 'c':
		cc += 1
af = s.find('a')
bf = s.find('b')
cf = s.find('c')
s = s[::-1]
ae = len(s) - s.find('a') - 1
be = len(s) - s.find('b') - 1
ce = len(s) - s.find('c') - 1
if af < bf and af < cf and (ae < bf) and (be < cf) and (ac == cc or cc == bc):
	print('YES')
else:
	print('NO')


def defno():
	print('NO')
	quit()
(a, b, c) = (0, 0, 0)
for i in input():
	if i == 'a':
		if b + c != 0:
			defno()
		a += 1
	elif i == 'b':
		if c != 0:
			defno()
		b += 1
	else:
		c += 1
if (c == a or c == b) and a > 0 and (b > 0):
	print('YES')
else:
	print('NO')


str = list(input())
(ca, cb, cc) = (0, 0, 0)
(swa, swb, swc) = (0, 0, 0)
if 'a' not in str or 'b' not in str or 'c' not in str:
	print('NO')
	exit()
for i in str:
	if swb == 1 and i == 'a' or (swc == 1 and (i == 'a' or i == 'b')):
		print('NO')
		exit()
	if i == 'a':
		swa = 1
		ca += 1
	if i == 'b':
		swb = 1
		cb += 1
	if i == 'c':
		swc = 1
		cc += 1
if cc == ca or cc == cb:
	print('YES')
else:
	print('NO')


data = input()
num = {'a': 0, 'b': 0, 'c': 0}
fa = True
fb = True
for i in data:
	if i == 'b':
		fa = False
	if i == 'c':
		fa = False
		fb = False
	if i == 'a' and fa == False:
		print('NO')
		quit()
	if i == 'b' and fb == False:
		print('NO')
		quit()
	num[i] += 1
if num['a'] == 0 or num['b'] == 0 or num['c'] == 0:
	print('NO')
	quit()
if num['c'] != num['a'] and num['c'] != num['b']:
	print('NO')
	quit()
print('Yes')


def no():
	print('NO')
	exit(0)
S = input()
if ''.join(sorted(S)) != S:
	no()
a = S.count('a')
b = S.count('b')
c = S.count('c')
if a + b + c != len(S):
	no()
if a == 0 or b == 0:
	no()
if c != a and c != b:
	no()
print('YES')


s = input()
a = []
x = s.count('a')
y = s.count('b')
z = s.count('c')
for i in range(0, len(s)):
	a.append(s[i])
c = s.count('a')
so = sorted(s)
if so == a and (x == z or y == z) and (x != 0) and (y != 0):
	print('YES')
else:
	print('NO')


myWord = input()
myList = list(myWord)
counterA = 0
counterB = 0
counterC = 0
indicator = 1
index = 0
for i in range(0, len(myList)):
	if indicator == 1:
		if myList[i] == 'a':
			counterA += 1
			indicator = 2
		else:
			print('NO')
			index = 1
			break
	elif indicator == 2:
		if myList[i] == 'a':
			counterA += 1
		elif myList[i] == 'b':
			indicator = 3
			counterB += 1
		elif myList[i] == 'c':
			print('NO')
			index = 1
			break
	elif indicator == 3:
		if myList[i] == 'a':
			print('NO')
			index = 1
			break
		elif myList[i] == 'b':
			counterB += 1
		elif myList[i] == 'c':
			counterC += 1
			indicator = 4
	elif indicator == 4:
		if myList[i] == 'c':
			counterC += 1
		else:
			print('NO')
			index = 1
			break
if index == 0:
	if counterA == counterC or counterB == counterC:
		if counterA != 0 and counterB != 0 and (counterC != 0):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


s = input()
x = 'a'
(ka, kb, kc) = (0, 0, 0)
for c in s:
	if c == 'a':
		if x == 'a':
			ka += 1
		else:
			print('NO')
			exit()
	elif c == 'b':
		if x == 'b':
			kb += 1
		elif x == 'a':
			kb = 1
			x = 'b'
		else:
			print('NO')
			exit()
	elif c == 'c':
		if x == 'c':
			kc += 1
		elif x == 'b':
			x = 'c'
			kc = 1
		else:
			print('NO')
			exit()
	else:
		print('NO')
		exit()
if kc == 0 or kb == 0 or ka == 0 or (kb != kc and ka != kc):
	print('NO')
else:
	print('YES')


s = input()
f_a = -1
f_b = -1
f_c = -1
cnt_a = 0
cnt_b = 0
cnt_c = 0
for i in range(1, len(s)):
	if ord(s[i]) < ord(s[i - 1]):
		print('NO')
		exit()
	if s[i] == 'a':
		cnt_a += 1
	if s[i] == 'b':
		cnt_b += 1
	if s[i] == 'c':
		cnt_c += 1
if s[0] == 'a':
	cnt_a += 1
if s[0] == 'b':
	cnt_b += 1
if s[0] == 'c':
	cnt_c += 1
if cnt_a < 1 or cnt_b < 1:
	print('NO')
	exit()
if cnt_c != cnt_a and cnt_c != cnt_b:
	print('NO')
else:
	print('YES')


n = str(input())
a = n.count('a')
b = n.count('b')
c = n.count('c')
e = []
for j in n:
	e.append(j)
h = sorted(e)
if (a < 1 or b < 1 or c < 1) or h != e:
	print('NO')
elif c != a and c != b:
	print('NO')
else:
	print('YES')


I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
n = len(s)
aa = s[:a]
ba = s[a:a + b]
ca = s[a + b:]
if (c == a or c == b) and list(set(aa)) == ['a'] and (list(set(ba)) == ['b']):
	print('YES')
else:
	print('NO')


s = str(input())
a = []
na = s.count('a')
nb = s.count('b')
nc = s.count('c')
if (nc == na or nc == nb) and na > 0 and (nb > 0):
	if 'ba' in s or 'cb' in s or 'ca' in s:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


string = input()
counta = 0
countb = 0
countc = 0
adone = 0
bdone = 0
for i in range(len(string)):
	if string[i] != 'a' and i == 0:
		print('NO')
		quit()
	if string[i] == 'a' and adone == 1:
		print('NO')
		quit()
	if string[i] == 'b' and bdone == 1:
		print('NO')
		quit()
	if string[i] == 'a':
		counta += 1
	if string[i] == 'b':
		adone = 1
		countb += 1
	if string[i] == 'c' and countb == 0 or (string[i] == 'c' and countc > counta and (countc > countb)):
		print('NO')
		quit()
	if string[i] == 'c':
		bdone = 1
		countc += 1
if counta == 0 or countb == 0 or countc == 0 or (countc != counta and countc != countb):
	print('NO')
else:
	print('YES')


import re
st = input()
if not re.match('^a+?b+?c+?$', st):
	print('NO')
else:
	print('YES' if st.count('c') == st.count('a') or st.count('c') == st.count('b') else 'NO')


import re
s = input()

def count(x):
	r = re.compile('{}+'.format(x))
	m = r.search(s)
	xa = len(m.group())
	return xa
r = re.compile('a+b+c+')
m = r.search(s)
if m != None and m.group() == s:
	xa = count('a')
	xb = count('b')
	xc = count('c')
	if xc == xa or xc == xb:
		print('YES')
	else:
		print('NO')
else:
	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')


texto = input()
pos_a = texto.find('a')
pos_b = texto.find('b')
pos_c = texto.find('c')
if texto[pos_b:].count('a') > 0 or texto[pos_c:].count('a') > 0 or texto[pos_c:].count('b') > 0:
	print('NO')
elif -1 < pos_a < pos_b < pos_c:
	a = texto.count('a')
	b = texto.count('b')
	c = texto.count('c')
	if a == c or b == c:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


data = input()
a = 0
b = 0
c = 0
k = 1
m = 'a'
if data[0] == 'a' and data[-1] == 'c':
	for x in data:
		if m != x:
			k += 1
		m = x
		if x == 'a':
			a += 1
		elif x == 'b':
			b += 1
		elif x == 'c':
			c += 1
	if a == 0 or b == 0 or c == 0 or (k != 3):
		print('NO')
	elif c == a or c == b:
		print('YES')
	else:
		print('No')
else:
	print('NO')


s = input()
k = 1
if sorted(s) != list(s):
	print('NO')
else:
	a = s.count('a')
	b = s.count('b')
	c = s.count('c')
	if (a != 0 and b != 0 and (c != 0)) and (c == a or c == b):
		print('YES')
	else:
		print('NO')


s = input()
if s.startswith('a') and s.endswith('c') and (list(s).count('c') == list(s).count('a') or list(s).count('c') == list(s).count('b')) and (sorted(list(s)) == list(s)) and ('a' in s) and ('b' in s):
	print('YES')
else:
	print('NO')


def check_string(st):
	i = 0
	while i != len(st) - 1:
		if ord(st[i]) > ord(st[i + 1]):
			return 'NO'
		else:
			i += 1
	if (st.count('a') == st.count('c') or st.count('b') == st.count('c')) and len(st.split('b')) != 1 and (len(st.split('a')) != 1):
		return 'YES'
	else:
		return 'NO'
print(check_string(input()))


def proc(s):
	a = True
	b = True
	c = True
	ac = 0
	bc = 0
	cc = 0
	for i in range(len(s)):
		if a:
			if s[i] != 'a':
				return False
		elif b:
			if s[i] != 'b' and s[i] != 'a':
				return False
		elif c:
			if s[i] != 'c' and s[i] != 'b':
				return False
		elif s[i] != 'c':
			return False
		if s[i] == 'a':
			ac += 1
			a = False
		elif s[i] == 'b':
			bc += 1
			b = False
		elif s[i] == 'c':
			cc += 1
			c = False
		if i == len(s) - 1:
			if ac == 0 or bc == 0:
				return False
			elif cc == ac or cc == bc:
				return True
			else:
				return False
s = input()
res = proc(s)
if res:
	print('YES')
else:
	print('NO')


s = input()
aCount = 0
bCount = 0
cCount = 0
mode = 'a'
for x in s:
	if mode == 'a':
		if x != 'a':
			if aCount == 0 or x == 'c':
				print('NO')
				exit()
			else:
				mode = 'b'
				bCount += 1
		else:
			aCount += 1
	elif mode == 'b':
		if x != 'b':
			if bCount == 0 or x == 'a':
				print('NO')
				exit()
			else:
				mode = 'c'
				cCount += 1
		else:
			bCount += 1
	elif mode == 'c':
		if x == 'b' or x == 'a':
			print('NO')
			exit()
		else:
			cCount += 1
if bCount == 0 or cCount == 0:
	print('NO')
	exit()
if cCount == aCount or cCount == bCount:
	print('YES')
	exit()
else:
	print('NO')
	exit()


s = input()
a = [s.count('a'), s.count('b'), s.count('c')]
if s == ''.join(sorted([ch for ch in s])) and min(a) > 0 and (a[2] in a[:2]):
	print('YES')
else:
	print('NO')


import re
s = input()
r = re.compile('a+b+c+')
m = r.search(s)
if m != None and m.group() == s:
	(xa, xb, xc) = (s.count('a'), s.count('b'), s.count('c'))
	if xc == xa or xc == xb:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
i1 = 0
i = 0
while s[i] == 'a':
	i += 1
	i1 += 1
	if i == len(s):
		break
i2 = 0
if i != len(s):
	while s[i] == 'b':
		i += 1
		i2 += 1
		if i == len(s):
			break
	i3 = 0
	if i != len(s):
		while s[i] == 'c':
			i += 1
			i3 += 1
			if i == len(s):
				break
if i == len(s) and i1 > 0 and (i2 > 0) and (i3 == i1 or i3 == i2):
	print('YES')
else:
	print('NO')


s = input()
l = len(s)
state = 0
acount = 1
bcount = 1
ccount = 1
for c in s:
	if c == 'a':
		if state == 0:
			state = 1
		elif state == 1:
			acount += 1
		else:
			state = -1
			break
	elif c == 'b':
		if state == 1:
			state = 2
		elif state == 2:
			bcount += 1
		else:
			state = -1
			break
	elif c == 'c':
		if state == 2:
			state = 3
		elif state == 3:
			ccount += 1
		else:
			state = -1
			break
if state == 3 and (acount == ccount or bcount == ccount):
	print('YES')
else:
	print('NO')


str = input()
cnt_a = 1
cnt_b = cnt_c = 0
flag = 0
for i in range(1, len(str)):
	if str[i] == 'a' and str[i - 1] == 'a':
		cnt_a += 1
	elif str[i] == 'b' and (str[i - 1] == 'b' or (str[i - 1] == 'a' and cnt_b == 0)):
		cnt_b += 1
	elif str[i] == 'c' and (str[i - 1] == 'c' or (str[i - 1] == 'b' and cnt_c == 0)):
		cnt_c += 1
	else:
		print('NO')
		exit()
if str[0] == 'a' and (cnt_c == cnt_a or cnt_c == cnt_b) and (cnt_b > 0):
	print('YES')
else:
	print('NO')


from sys import stdin
rInt = lambda : int(stdin.readline().strip('\n'))
rIntArray = lambda : [int(x) for x in stdin.readline().split()]
rString = lambda : stdin.readline().strip('\n')
rStrArray = lambda : [x for x in stdin.readline().split()]
stretch = 'a'
cou = {'a': 0, 'b': 0, 'c': 0}
flag = True
for i in rString():
	if i < stretch:
		flag = False
	if i != stretch:
		stretch = i
	cou[i] += 1
if cou['a'] == 0 or cou['b'] == 0:
	flag = False
if cou['c'] != cou['a'] and cou['c'] != cou['b']:
	flag = False
print('YES' if flag else 'NO')


s = input()
if s[0] == 'b':
	print('NO')
	exit()
a = s.count('a')
b = s.count('b')
print(('NO', 'YES')[a * b and s in ('a' * a + 'b' * b + 'c' * i for i in (a, b))])


s = str(input())
a = s.find('a')
b = s.find('b')
c = s.find('c')
if 'a' in s and 'b' in s and ('b' in s) and (a < b < c) and ('ba' not in s) and ('ca' not in s) and ('cb' not in s):
	if s.count('a') == s.count('c') or s.count('b') == s.count('c'):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a != 0:
	ind_a = s.index('a')
if b != 0:
	ind_b = s.index('b')
if c != 0:
	ind_c = s.index('c')
if a == 0 or b == 0 or c == 0:
	print('NO')
elif ind_a > ind_b or ind_a > ind_c or ind_b > ind_c:
	print('NO')
elif s[:ind_b].count('a') != a or s[ind_b:ind_c].count('b') != b or s[ind_c:].count('c') != c:
	print('NO')
elif c != a and c != b:
	print('NO')
else:
	print('YES')


s = input()
da = db = dc = 0
expected = 'a'
for c in s:
	next = chr(ord(expected) + 1)
	if c == next:
		expected = next
	elif c != expected:
		print('NO')
		exit()
	if c == 'a':
		da += 1
	elif c == 'b':
		db += 1
	elif c == 'c':
		dc += 1
if (da == 0 or db == 0 or dc == 0) or (da != dc and db != dc):
	print('NO')
	exit()
print('YES')


s = input()

def is_string_possible(s):
	num_of_a = s.count('a') or 0
	num_of_b = s.count('b') or 0
	num_of_c = s.count('c') or 0
	ab = s.count('ab')
	ba = s.count('ba')
	bc = s.count('bc')
	cb = s.count('cb')
	ac = s.count('ac')
	ca = s.count('ca')
	if num_of_a == 0 or num_of_b == 0:
		return 'NO'
	if ab > 1 or bc > 1 or ac > 0 or (ba > 0) or (cb > 0) or (ca > 0):
		return 'NO'
	elif num_of_a != num_of_c and num_of_b != num_of_c:
		return 'NO'
	return 'YES'
print(is_string_possible(s))


from typing import Dict, List, Tuple

def input_lst() -> List[int]:
	return [int(x) for x in input().split()]

def print_out(res: List[int]):
	print(' '.join([str(x) for x in res]))

def get_simple_numbers_less_than(n: int) -> List[int]:
	pr = []
	lp = [0] * (n - 2)
	for i in range(n - 2):
		if lp[i] == 0:
			lp[i] = i
			pr.append(i)
		for p in pr:
			if p > lp[i] or p * i > n:
				break
			lp[p * i] = p
	return pr

def main():
	s = input()
	res = [0, 0, 0]
	good = True
	for el in s:
		if el == 'a':
			if res[1] == 0 and res[2] == 0:
				res[0] += 1
			else:
				good = False
		if el == 'b':
			if res[0] > 0 and res[2] == 0:
				res[1] += 1
			else:
				good = False
		if el == 'c':
			if res[0] > 0 and res[1] > 0:
				res[2] += 1
			else:
				good = False
	if good and (res[0] > 0 and res[1] > 0 and (res[2] > 0)) and (res[2] == res[0] or res[2] == res[1]):
		print('YES')
	else:
		print('NO')
main()


from collections import Counter
s = input()
ss = s
s = tuple(list(s))
d = Counter(s)
res = ''
res = res + 'a' * d['a']
res = res + 'b' * d['b']
res = res + 'c' * d['c']
if res == ss and d['a'] > 0 and (d['b'] > 0) and (d['c'] == d['a'] or d['c'] == d['b']):
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from math import *
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
t = sorted(s)
t = ''.join(t)
if a > 0 and b > 0 and (a == c or b == c) and (t == s):
	print('YES')
else:
	print('NO')


def solution(string):
	a = b = c = 0
	i = 0
	for p in string:
		if p != 'a':
			break
		i += 1
		a += 1
	for p in string[i:]:
		if p != 'b':
			break
		i += 1
		b += 1
	for p in string[i:]:
		if p != 'c':
			break
		i += 1
		c += 1
	if a + b + c != len(string) or a == 0 or b == 0 or (c == 0):
		return 'NO'
	elif a == c or b == c:
		return 'YES'
	else:
		return 'NO'
string = input()
print(solution(string))


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')


a = input()
if a.find('b') < a.find('a') or a.find('c') < a.find('a') or a.find('c') < a.find('b') or ('a' not in a) or ('b' not in a) or ('c' not in a):
	print('NO')
elif a.count('c') != a.count('a') and a.count('c') != a.count('b'):
	print('NO')
elif a.find('b') < a.rfind('a') or a.find('c') < a.rfind('a') or a.find('c') < a.rfind('b'):
	print('NO')
else:
	print('YES')


a = input()
x = 1
for i in range(len(a) - 1):
	if a[i] > a[i + 1]:
		x = 0
		break
p = a.count('a')
q = a.count('b')
r = a.count('c')
if x and p and q and r and (p == r or q == r):
	print('YES')
else:
	print('NO')


s = input()
two = s.count('c') == s.count('a') or s.count('c') == s.count('b')
(first, second, third) = (0, 0, 0)
if 'a' in s:
	first = s[s.find('a'):s.rfind('a')].count('b') + s[s.find('a'):s.rfind('a')].count('c') == 0
if 'b' in s:
	second = s[s.find('b'):s.rfind('b')].count('c') + s[s.find('b'):s.rfind('b')].count('a') == 0
if 'c' in s:
	third = s[s.find('c'):s.rfind('c')].count('b') + s[s.find('c'):s.rfind('c')].count('a') == 0
chars = ''
for i in s:
	if i not in chars:
		chars += i
if two and first and second and third and (chars in 'abc'):
	print('YES')
else:
	print('NO')


def increase(a):
	t = a[0]
	for i in range(1, len(a)):
		if a[i] >= t:
			t = a[i]
		else:
			return False
	return True
a = input()
if (a.count('c') == a.count('b') or a.count('c') == a.count('a')) and 'b' in a and ('a' in a):
	if increase(a):
		print('YES')
	else:
		print('NO')
else:
	print('No')


def is_ok(s):
	p1 = s.find('ab')
	p2 = s.find('bc')
	if p1 == -1 or p2 == -1 or p2 < p1:
		return False
	A = s[:p1 + 1]
	B = s[p1 + 1:p2 + 1]
	C = s[p2 + 1:]
	if A == 'a' * len(A) and B == 'b' * len(B) and (C == 'c' * len(C)) and (len(C) == len(B) or len(C) == len(A)):
		return True
	return False
s = input()
if is_ok(s):
	print('YES')
else:
	print('NO')


s = input().rstrip()

def solve(s):
	res = []
	counter = 1
	for i in range(1, len(s)):
		if s[i - 1] == s[i]:
			counter += 1
		else:
			res.append([s[i - 1], counter])
			counter = 1
	res.append([s[-1], counter])
	return res
r = solve(s)
if len(r) != 3:
	print('NO')
	exit()
if r[0][0] == 'a' and r[1][0] == 'b' and (r[2][0] == 'c') and (len(r) == 3):
	if r[2][1] == r[0][1] or r[2][1] == r[1][1]:
		print('YES')
		exit()
print('NO')


letters = input()

def main():
	ass = 0
	bss = 0
	css = 0
	valid = True
	state = None
	for l in letters:
		if l == 'a':
			ass += 1
			if state == None:
				state = 'A'
			elif state != 'A':
				valid = False
				break
		elif l == 'b':
			bss += 1
			if state == 'A':
				state = 'B'
			elif state != 'B':
				valid = False
				break
		else:
			css += 1
			if state == 'B':
				state = 'C'
			elif state != 'C':
				valid = False
				break
	if not valid:
		print('NO')
		return
	if css == 0 or (css != ass and css != bss):
		print('NO')
		return
	print('YES')
main()


s = input()
n = len(s)
p1 = 0
p2 = 0
flag = True
ch = ['a', 'b', 'c']
cnn = len(ch)
cn = [0, 0, 0]
i = 0
while p2 < n and i < cnn:
	if s[p1] != ch[i]:
		flag = False
		break
	while p2 < n and s[p2] == ch[i]:
		p2 += 1
	cn[i] = p2 - p1
	p1 = p2
	i += 1
if p2 != n:
	flag = False
for i in range(cnn):
	if cn[i] == 0:
		flag = False
if cn[2] != cn[1] and cn[2] != cn[0]:
	flag = False
if flag:
	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')


s = input()
if s.count('c') == 0 or s.count('a') == 0 or s.count('b') == 0:
	print('NO')
elif list(s) == sorted(s):
	if s.count('c') == s.count('a') or s.count('c') == s.count('b'):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


from sys import setcheckinterval, stdin
setcheckinterval(1000)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
s = input()
a = []
ch = 0
pv = 'a'
for i in s:
	if pv == i:
		ch += 1
	else:
		if ch:
			a.append([pv, ch])
		ch = 1
		pv = i
else:
	a.append([pv, ch])
if len(a) != 3 or (a[0][0], a[1][0], a[2][0]) != ('a', 'b', 'c'):
	print('NO')
elif a[2][1] == a[1][1] or a[2][1] == a[0][1]:
	print('YES')
else:
	print('NO')


a = input()
a = [i for i in a]
a1 = ''.join(a)
b = list(sorted(set(a), key=a.index))
c = 0
if b == ['a', 'b', 'c']:
	c += 1
if a.count('a') == a.count('c') or a.count('b') == a.count('c'):
	c += 1
if a1.rfind('a') < a1.find('b') and a1.rfind('a') < a1.find('c') and (a1.rfind('b') < a1.find('c')):
	c += 1
if c == 3:
	print('YES')
else:
	print('NO')


st = input()
if st.count('a') != 0 and st.count('b') != 0 and (st.count('c') != 0) and (st == ''.join(sorted(st))) and (st.count('c') == st.count('a') or st.count('c') == st.count('b')):
	print('YES')
else:
	print('NO')


a = str(input())
ca = 0
cc = 0
cb = 0
k = 0
if len(a) == 0:
	print('NO')
	exit()
elif a[0] == 'a':
	for i in range(len(a)):
		if a[i] == 'a':
			ca = ca + 1
		else:
			k = i
			break
	for j in range(k, len(a)):
		if a[j] == 'b':
			cb = cb + 1
		else:
			k = j
			break
	for t in range(k, len(a)):
		if a[t] == 'c':
			cc = cc + 1
		else:
			break
	if cb >= 1:
		if ca + cb + cc == len(a):
			if cc == ca or cc == cb:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


s = input('')
na = s.count('a')
nb = s.count('b')
nc = s.count('c')
if nb == 0 or na == 0 or nc == 0:
	print('NO')
elif nc != na and nc != nb:
	print('NO')
else:
	flag = 0
	for i in range(len(s) - 1):
		if s[i] == 'a':
			if s[i + 1] == 'c':
				flag = 1
				break
		elif s[i] == 'b':
			if s[i + 1] == 'a':
				flag = 1
				break
		elif s[i + 1] != 'c':
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


from sys import stdin
from collections import deque
import sys
import math
s = input()
s = list(s)
(a, b, c) = (0, 0, 0)
if s[-1] == 'c':
	while len(s) > 0 and s[-1] == 'c':
		s.pop()
		c += 1
else:
	print('NO')
	sys.exit()
if len(s) > 0 and s[-1] == 'b':
	while len(s) > 0 and s[-1] == 'b':
		s.pop()
		b += 1
else:
	print('NO')
	sys.exit()
if len(s) > 0 and s[-1] == 'a':
	while len(s) > 0 and s[-1] == 'a':
		s.pop()
		a += 1
else:
	print('NO')
	sys.exit()
if (c == a or c == b) and len(s) == 0:
	print('YES')
else:
	print('NO')


lett = 'a'
d = dict()
d['a'] = d['b'] = d['c'] = 0
for i in input():
	d[i] += 1
	if i < lett:
		exit(print('NO'))
	if i > lett:
		lett = i
print('YES' if (d['c'] == d['b'] or d['c'] == d['a']) and d['a'] and d['b'] and d['c'] else 'NO')


import re
string = input()
if re.match('a+b+c+$', string):
	count = {'a': 0, 'b': 0, 'c': 0}
	for ch in string:
		count[ch] += 1
	if count['a'] == count['c'] or count['b'] == count['c']:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def solve(test):
	p = ['a', 'b', 'c', '#']
	d = [0, 0, 0]
	i = 0
	for ch in test:
		if p[i] == ch:
			d[i] += 1
		elif p[i + 1] == ch:
			i += 1
			d[i] += 1
		else:
			return 'NO'
	clean = d[0] != 0 and d[1] != 0 and (d[2] != 0) and (i == 2)
	if clean and (d[2] == d[1] or d[2] == d[0]):
		return 'YES'
	else:
		return 'NO'
test = input()
print(solve(test))


l = input()
n = len(l)
a = []
count = 0
for x in range(n):
	if x != n - 1:
		if l[x] == l[x + 1]:
			count += 1
		else:
			count += 1
			a.append(l[x] * count)
			count = 0
	elif l[x] == l[x - 1]:
		count += 1
		a.append(l[x] * count)
	else:
		a.append(l[x])
k = len(a)
if k == 3 and a[0][0] == 'a' and (a[1][0] == 'b') and (a[2][0] == 'c') and (len(a[0]) == len(a[2]) or len(a[1]) == len(a[2])):
	print('YES')
else:
	print('NO')


s = input()
x1 = s.find('a')
x2 = s.find('b')
x3 = s.find('c')
s1 = s[x1:x2]
s2 = s[x2:x3]
s3 = s[x3:]
if 'b' not in s1 and 'c' not in s1 and ('a' not in s2) and ('c' not in s2) and ('a' not in s3) and ('b' not in s3) and (len(s1) > 0) and (len(s2) > 0) and (len(s3) > 0) and (len(s3) == len(s1) or len(s3) == len(s2)):
	print('YES')
else:
	print('NO')


import sys
a = list(input())
oj = 'a'
for i in range(len(a)):
	if a[i] != oj:
		if oj == 'a' and a[i] == 'b':
			oj = 'b'
		elif oj == 'b' and a[i] == 'c':
			oj = 'c'
		else:
			print('NO')
			sys.exit()
C = a.count('c')
A = a.count('a')
B = a.count('b')
if (C == A or C == B) and (A and B and C):
	print('YES')
else:
	print('NO')


s = input()
afound = False
bfound = False
cfound = False
if len(s) < 3:
	print('NO')
	exit()
for c in s:
	if c == 'a':
		if bfound or cfound:
			print('NO')
			exit()
		afound = True
	if c == 'b':
		if not afound:
			print('NO')
			exit()
		if cfound:
			print('NO')
			exit()
		bfound = True
	if c == 'c':
		cfound = True
a = len([x for x in s if x == 'a'])
b = len([x for x in s if x == 'b'])
c = len([x for x in s if x == 'c'])
if a == 0 or b == 0 or c == 0:
	print('NO')
	exit()
if c == a:
	print('YES')
	exit()
if c == b:
	print('YES')
	exit()
print('NO')


import sys
data = sys.stdin.readlines()[0].split()[0]
counters = [0, 0, 0]
ok = True
for (idx, letter) in enumerate(data):
	if idx > 0:
		if letter >= data[idx - 1]:
			counters[ord(letter) - ord('a')] += 1
		else:
			ok = False
			break
	else:
		counters[ord(letter) - ord('a')] += 1
if counters[0] > 0 and counters[1] > 0 and (counters[2] == counters[0] or counters[2] == counters[1]) and (ok is True):
	print('YES')
else:
	print('NO')


str1 = input()
index = 0
str2 = 'a' * str1.count('a') + 'b' * str1.count('b') + 'c' * str1.count('c')
if (str1.count('c') == str1.count('b') or str1.count('c') == str1.count('a')) and str1.count('a') and str1.count('b'):
	index = 1
if str1 == str2 and index == 1:
	print('YES')
else:
	print('NO')


s = input()
step = 0
flag = 1
suma = 0
sumb = 0
sumc = 0
for i in range(len(s)):
	if s[i] != 'a':
		step = i
		break
	suma += 1
for i in range(step, len(s)):
	if s[i] != 'b':
		step = i
		break
	sumb += 1
for i in range(step, len(s)):
	if s[i] != 'c':
		flag = 0
		break
	sumc += 1
	step = i
if step != len(s) - 1:
	flag = 0
if suma > 0 and sumb > 0 and (sumc > 0) and (sumc == suma or sumc == sumb) and (flag == 1):
	print('YES')
else:
	print('NO')


string = input()
x = 'abc'
k = 0
s = 0
flag = True
if string.count('b') == 0 or string.count('a') == 0:
	print('NO')
	flag = False
if flag:
	for i in x:
		if string[s:string.count(i) + s].count(i) != string.count(i):
			print('NO')
			flag = False
			break
		s += string.count(i)
if flag:
	if string.count('a') == string.count('c') or string.count('b') == string.count('c'):
		print('YES')
	else:
		print('NO')


def func():
	(acon, bcon, con) = (0, 0, 0)
	(acount, bcount, count) = (0, 0, 0)
	for i in s:
		if i == 'a':
			acon = 1
			if bcon == 1 or con == 1:
				return 'NO'
			acount = acount + 1
		if i == 'b':
			bcon = 1
			if con == 1:
				return 'NO'
			bcount = bcount + 1
		if i == 'c':
			con = 1
			count = count + 1
	if acount == 0 or bcount == 0 or count == 0:
		return 'NO'
	elif acount == count or bcount == count:
		return 'YES'
	else:
		return 'NO'
s = str(input().strip())
result = func()
print(result)


s = input()
mas = ['']
q = 0
for i in range(len(s) - 1):
	mas[q] += s[i]
	if s[i] != s[i + 1]:
		q += 1
		mas.append('')
mas[q] += s[len(s) - 1]
if len(mas) == 3 and 'a' in mas[0] and ('b' in mas[1]) and ('c' in mas[2]) and (len(mas[0]) == len(mas[2]) or len(mas[1]) == len(mas[2])):
	print('YES')
else:
	print('NO')


import re
nbA = 0
nbB = 0
nbC = 0
ch = input()
nbA = ch.count('a')
nbB = ch.count('b')
nbC = ch.count('c')
if re.match('a+b+c+$', ch) and nbA == nbC or (re.match('a+b+c+$', ch) and nbC == nbB) or (re.match('a+b+c+$', ch) and nbA == nbC and (nbC == nbB)):
	print('YES')
else:
	print('NO')


inp = input()
a_count = 0
b_count = 0
c_count = 0
flag = False
for i in range(0, len(inp) - 1):
	if inp[i] == 'a':
		if inp[i + 1] != 'b' and inp[i + 1] != 'a':
			flag = True
			break
		else:
			a_count += 1
	if inp[i] == 'b':
		if inp[i + 1] != 'b' and inp[i + 1] != 'c':
			flag = True
			break
		else:
			b_count += 1
	if inp[i] == 'c':
		if inp[i + 1] != 'c':
			flag = True
			break
		else:
			c_count += 1
if inp[len(inp) - 1] != 'c':
	flag = True
else:
	c_count += 1
if c_count != a_count and c_count != b_count or a_count == 0 or b_count == 0:
	flag = True
if flag == True:
	print('NO')
else:
	print('YES')


TN = 1

def solution():
	s = list(input())
	s1 = sorted(s)
	if s != s1:
		print('NO')
	else:
		a = s.count('a')
		b = s.count('b')
		c = s.count('c')
		if a > 0 and b > 0 and (c == a or c == b):
			print('YES')
		else:
			print('NO')
while TN != 0:
	solution()
	TN -= 1


a1 = input()
tt = a1
a1 = list(a1)
tt = list(tt)
tt.sort()
f = set(a1)
f = list(f)
if len(f) < 3:
	print('NO')
	exit()
if a1 != tt:
	print('NO')
else:
	a = tt.count('a')
	b = tt.count('b')
	c = tt.count('c')
	if a == c or b == c:
		print('YES')
	else:
		print('NO')


s = input()
n1 = s.count('a')
n2 = s.count('b')
n3 = s.count('c')
n4 = s.count('ab')
n5 = s.count('ba')
if (n1 == n3 or n2 == n3) and n4 == 1 and (n5 == 0) and (s[-n3:].count('c') == n3):
	print('YES')
else:
	print('NO')


from itertools import groupby

def solve(s):
	i = 0
	for (c, g) in groupby(s):
		if i == 0:
			if c != 'a':
				return 'NO'
			xa = len(list(g))
			i += 1
		elif i == 1:
			if c != 'b':
				return 'NO'
			xb = len(list(g))
			i += 1
		elif i == 2:
			if c != 'c':
				return 'NO'
			xc = len(list(g))
			i += 1
		else:
			return 'NO'
	return 'YES' if i == 3 and xc in (xa, xb) else 'NO'
print(solve(input()))


import re
s = input()
r = re.compile('^a+b+c+$')
m = r.search(s)
print(('NO', 'YES')[m != None and s.count('c') in (s.count('a'), s.count('b'))])


s = input()
try:
	a_stop = s.rindex('a')
	a_start = s.index('a')
	b_stop = s.rindex('b')
	b_start = s.index('b')
	c_start = s.index('c')
	c_stop = s.rindex('c')
	if a_stop > b_start or b_stop > c_start:
		print('NO')
	elif len(s[c_start:]) == len(s[b_start:b_stop + 1]) or len(s[c_start:]) == len(s[:a_stop + 1]):
		print('YES')
	else:
		print('NO')
except ValueError:
	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)
	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()


aa = str(input())
a = 0
b = 0
c = 0
if aa[0] == 'a':
	corect = 1
	for i in aa:
		if i == 'a':
			a += 1
			if corect != 1:
				c = -1
				break
			corect = 1
		elif i == 'b':
			b += 1
			if corect == 3:
				c = -1
				break
			corect = 2
		elif i == 'c':
			c += 1
			if corect == 1:
				c = -1
				break
			corect = 3
	if a == c or (b == c and (a != 0 and b != 0)):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(z, zz, dgraphs, mod) = (input, lambda : list(map(int, z().split())), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
l = z()
a = l.count('a')
b = l.count('b')
c = l.count('c')
if 'ba' in l or 'ca' in l or 'cb' in l:
	exit(print('NO'))
elif (c == a or c == b) and len(set(l)) == 3:
	t = 0
	d = 0
	for i in l[:a]:
		if i == 'a':
			d += 1
	if d == a:
		t += 1
	d = 0
	for i in l[a:a + b]:
		if i == 'b':
			d += 1
	if d == b:
		t += 1
	d = 0
	for i in l[a + b:a + b + c]:
		if i == 'c':
			d += 1
	if d == c:
		t += 1
	if t == 3:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


s = input()
print('YES' if (s.rfind('a') < s.find('b')) & (s.rfind('b') < s.find('c')) & ((s.count('c') == s.count('a')) | (s.count('c') == s.count('b'))) & (s.count('a') != 0) & (s.count('b') != 0) & (s.count('c') != 0) else 'NO')


s = input() + 'd'
d = []
(r, l) = (0, 0)
e = set()
while r != len(s):
	if s[r] != s[l]:
		d.append(s[l:r])
		l = r
	r += 1
if d[-1][0] != 'c' or d[0][0] != 'a' or d[1][0] != 'b' or (len(d) != 3):
	print('NO')
elif len(d[-1]) != len(d[0]) and len(d[-1]) != len(d[1]):
	print('NO')
else:
	print('YES')


s = input()
sl = s[::-1]
n = len(s)
if s.count('a') >= 1 and s.count('b') >= 1:
	if s.count('c') == s.count('a') or s.count('c') == s.count('b'):
		(a, b) = (n - sl.index('a'), n - sl.index('b'))
		(c, d) = (s.index('a'), s.index('b'))
		(e, f) = (a - c, b - d)
		(e, f) = ('a' * e, 'b' * f)
		if c < d and d < s.index('c') and (s[c:a] == e) and (s[d:b] == f):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


a = input()
B = a.count('b')
if a[0] != 'a' or len(a) == 2 or B == 0:
	print('NO')
else:
	flagonlyAencountered = True
	flagonlyBencountered = True
	flagending1 = True
	flagending2 = True
	countofa = 0
	countofb = 0
	countofc = 0
	for i in range(len(a)):
		if a[i] == 'a' and flagonlyAencountered:
			countofa += 1
		if a[i] == 'a' and flagonlyAencountered == False:
			countofa += 1
			flagending1 = False
			break
		if a[i] == 'b' and flagonlyBencountered:
			countofb += 1
			flagonlyAencountered = False
		if a[i] == 'b' and flagonlyBencountered == False:
			countofb += 1
			flagending2 = False
			break
		if a[i] == 'c':
			countofc += 1
			flagonlyBencountered = False
			flagonlyAencountered = False
	if (countofc == countofb or countofc == countofa) and (flagonlyBencountered == False and flagonlyAencountered == False and (flagending1 == True) and (flagending2 == True)):
		print('YES')
	elif flagending2 == False:
		print('NO')
	elif flagending1 == False:
		print('NO')
	else:
		print('NO')


s = input().strip()
(na, nb, nc) = (0, 0, 0)
for e in s:
	if e == 'a':
		na += 1
	elif e == 'b':
		nb += 1
	elif e == 'c':
		nc += 1
if na * nb == 0 or (na != nc and nb != nc):
	print('NO')
	exit(0)
res = list()
res.extend('a' * na)
res.extend('b' * nb)
res.extend('c' * nc)
res = ''.join(map(str, res))
print('YES') if s == res else print('NO')


s = input()
d = list(set(s))
d.sort()
n = len(s)
ans = 1
if d == ['a', 'b', 'c']:
	for i in range(1, n):
		if s[i] < s[i - 1]:
			ans = -1
	cnta = 0
	cntb = 0
	cntc = 0
	for i in range(n):
		if s[i] == 'a':
			cnta += 1
		if s[i] == 'b':
			cntb += 1
		if s[i] == 'c':
			cntc += 1
	if cntc != cnta and cntc != cntb:
		ans = -1
else:
	ans = -1
if ans == -1:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout
s = stdin.readline().strip()
(a, b, c) = (s.count('a'), s.count('b'), s.count('c'))
if a and b and c and ('a' * a + 'b' * b + 'c' * c == s) and (c == a or c == b):
	stdout.write('YES')
else:
	stdout.write('NO')


st = input()
if 'a' in st and 'b' in st and ('c' in st) and (st.count('c') == st.count('a') or st.count('c') == st.count('b')):
	f = False
	for (i, j) in enumerate(st[:-1]):
		if j == st[i + 1] or (j == 'a' and st[i + 1] == 'b') or (j == 'b' and st[i + 1] == 'c'):
			continue
		else:
			print('NO')
			f = True
			break
	if f == False:
		print('YES')
else:
	print('NO')


S = input()
(A, B, C) = ([], [], [])
for (i, v) in enumerate(S):
	if v == 'a':
		A += [i]
	if v == 'b':
		B += [i]
	if v == 'c':
		C += [i]
if A != [] and B != [] and (C != []) and (A[-1] < B[0]) and (B[-1] < C[0]) and (len(C) == len(A) or len(C) == len(B)):
	print('YES')
else:
	print('NO')