305066: CF960A. Check the string

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Check the string

题意翻译

A有一个由若干小写英文字母“a”组成的字符串。他把它给了他的朋友B,他的朋友B在这个字符串的末尾附加了一些字母“b”。因为AA和BB都喜欢字母“a”和“b”,他们已经确保在这一点上,字符串中至少有一个a和一个b。 现在B把这个字符串给了C,并在字符串的末尾添加了一些字母“c”。但是,因为C是A和B的好朋友,所以他添加的字母c的数量等于a的数量或者字符串中的b的数量。也有可能字母c的数量同时等于字母a的数量和字母b的数量。 您手中有一个字符串,您想检查这个字符串是否符合上述要求。如果符合,请输出YES,否则输出NO

题目描述

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

输入输出格式

输入格式


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

输出格式


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

输入输出样例

输入样例 #1

aaabccc

输出样例 #1

YES

输入样例 #2

bbacc

输出样例 #2

NO

输入样例 #3

aabc

输出样例 #3

YES

说明

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

Input

题意翻译

A有一个由若干小写英文字母“a”组成的字符串。他把它给了他的朋友B,他的朋友B在这个字符串的末尾附加了一些字母“b”。因为AA和BB都喜欢字母“a”和“b”,他们已经确保在这一点上,字符串中至少有一个a和一个b。 现在B把这个字符串给了C,并在字符串的末尾添加了一些字母“c”。但是,因为C是A和B的好朋友,所以他添加的字母c的数量等于a的数量或者字符串中的b的数量。也有可能字母c的数量同时等于字母a的数量和字母b的数量。 您手中有一个字符串,您想检查这个字符串是否符合上述要求。如果符合,请输出YES,否则输出NO

加入题单

上一题 下一题 算法标签: