#K10086. Beautiful String Rearrangement

    ID: 23168 Type: Default 1000ms 256MiB

Beautiful String Rearrangement

Beautiful String Rearrangement

You are given a string s consisting only of lowercase English letters. Your task is to determine whether it is possible to rearrange the characters of the string such that no two adjacent characters are identical. In other words, after rearrangement, the string should not contain any consecutive identical characters.

The necessary and sufficient condition for such a rearrangement to be possible is that the frequency f of the most frequent character satisfies the inequality:

$$ f \le \left\lceil \frac{|s|}{2} \right\rceil $$

If the condition holds, output YES, otherwise output NO.

inputFormat

The input is read from stdin and consists of a single line containing the string s, where s consists only of lowercase English letters.

outputFormat

Print a single line to stdout containing YES if the string can be rearranged into a beautiful string, otherwise print NO.

## sample
aabb
YES