960A.md (1759B)
1 Source: https://codeforces.com/problemset/problem/960/A 2 3 A. Check the string 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 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. 24 25 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). 26 27 Input 28 29 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'. 30 31 Output 32 33 Print "YES" or "NO", according to the condition. 34 35 Examples 36 37 Input 38 39 ``` 40 aaabccc 41 ``` 42 43 Output 44 45 ``` 46 YES 47 ``` 48 49 Input 50 51 ``` 52 bbacc 53 ``` 54 55 Output 56 57 ``` 58 NO 59 ``` 60 61 Input 62 63 ``` 64 aabc 65 ``` 66 67 Output 68 69 ``` 70 YES 71 ``` 72 73 Note 74 75 Consider first example: the number of 'c' is equal to the number of 'a'. 76 77 Consider second example: although the number of 'c' is equal to the number of the 'b', the order is not correct. 78 79 Consider third example: the number of 'c' is equal to the number of 'b'.