s=str(input())
l=list(s)
l.sort()
s1="".join(l)
if (s1==s) and ((l.count("c")==l.count("b")) or (l.count("c")==l.count("a"))) and (l.count("a")!=0) and (l.count("b")!=0):
print("YES")
else:
print("NO")
#include <iostream>
#include <algorithm>
#include <math.h>
#include "string.h"
#include <vector>
#include <stack>
#include <queue>
using namespace std;
struct Node
{
int val = 0;
Node *le = nullptr;
Node *ri = nullptr;
};
Node *head;
void setVal(Node **cur, int pos, int cle, int cri)
{
//cout << "cle=" << cle << ", cri=" << cri << ", cur=" << cur << "\n";
if ((*cur) == nullptr)
{
(*cur) = new Node;
}
if (cle == cri)
{
(*cur)->val = 1;
return;
}
int m = (cle+cri)/2;
if (pos <= m)
{
setVal(&((*cur)->le), pos, cle, m);
}
else
{
setVal(&((*cur)->ri), pos, m+1, cri);
}
((*cur)->val)++;
}
int getAns(Node *cur, int le, int ri, int cle, int cri)
{
if (cur == nullptr || le > ri)
{
return 0;
}
if (le == cle && ri == cri)
{
return cur->val;
}
int m = (cri+cle)/2;
return getAns(cur->le, le, min(ri, m), cle, m) +
getAns(cur->ri, max(le, m+1), ri, m+1, cri);
}
char op[3][4] = {"MOV", "ADD", "SUB"};
uint8_t r[4];
char cmd[100000];
void opReg(int rix, int st, int val)
{
rix--;
switch(st)
{
case 0:
r[rix] = val;
break;
case 1:
r[rix] += val;
break;
case 2:
r[rix] -= val;
break;
}
cout << "r" << rix + 1 << "=" << (int)r[rix] << "\n";
}
bool isRegOk(int ix, int le, int &rix)
{
if (cmd[ix] < '1' || cmd[ix] > '4')
{
return false;
}
if (ix + 1 < le && (cmd[ix+1] == ' ' || cmd[ix+1] == ','))
{
rix = cmd[ix] - '0';
return true;
}
if (ix + 1 >= le)
{
rix = cmd[ix] - '0';
return true;
}
return false;
}
bool isDigit(char ch)
{
return (ch >= '0' && ch <= '9');
}
bool isNum(int ix, int le, int &val)
{
cerr << "isNum for " << cmd + ix << "\n";
int res = 0;
if (!isDigit(cmd[ix]))
{
return false;
}
res = cmd[ix] - '0';
ix++;
while (ix < le && isDigit(cmd[ix]))
{
res *= 10;
res += cmd[ix] - '0';
ix++;
}
//cout << "res=" << "\n";
if ((ix < le && (cmd[ix] == ' ' || cmd[ix] == '\r')) || ix == le)
{
val = res;
cout << "val=" << val << "\n";
return true;
}
//cout << "bug\n";
return false;
}
char s[5001];
void solve()
{
int n;
cin >> s;
n = strlen(s);
int c[2] = {0,0};
int pos = 0;
int cc =0;
while (pos < n && s[pos] == 'a') {c[0]++; pos++;}
while (pos < n && s[pos] == 'b') {c[1]++; pos++;}
while (pos < n && s[pos] == 'c') {cc++; pos++;}
if (pos < n || c[0] == 0 || c[1] == 0 || (c[0] != cc && c[1] != cc))
{
cout << "NO\n";
}
else
{
cout << "YES\n";
}
return;
}
void precalc()
{
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int t = 1;
//cin >> t;
precalc();
for (int i = 0; i < t; ++i)
{
solve();
}
return 0;
}
1722D - Line | 1722C - Word Game |
1722G - Even-Odd XOR | 552E - Vanya and Brackets |
933A - A Twisty Movement | 1722F - L-shapes |
1196B - Odd Sum Segments | 1325D - Ehab the Xorcist |
552B - Vanya and Books | 1722E - Counting Rectangles |
168A - Wizards and Demonstration | 168B - Wizards and Minimal Spell |
7A - Kalevitch and Chess | 912B - New Year's Eve |
1537C - Challenging Cliffs | 879B - Table Tennis |
1674E - Breaking the Wall | 1282A - Temporarily unavailable |
1366C - Palindromic Paths | 336A - Vasily the Bear and Triangle |
926A - 2-3-numbers | 276D - Little Girl and Maximum XOR |
1253C - Sweets Eating | 1047A - Little C Loves 3 I |
758D - Ability To Convert | 733A - Grasshopper And the String |
216A - Tiling with Hexagons | 1351B - Square |
1225A - Forgetting Things | 1717A - Madoka and Strange Thoughts |