#K69662. Uniform Binary String Transformation

    ID: 33137 Type: Default 1000ms 256MiB

Uniform Binary String Transformation

Uniform Binary String Transformation

Given a binary string \(S\), determine whether it is possible to make all the characters in \(S\) identical by performing at most one flip operation.

A flip operation is defined as selecting a contiguous segment of \(S\) and inverting every character in that segment (i.e., converting '0' to '1' and '1' to '0').

Let \(r_0\) be the number of contiguous groups of '0's and \(r_1\) be the number of contiguous groups of '1's in \(S\). It can be shown that the string can be made uniform if and only if \(\min(r_0, r_1) \le 1\). Output YES if it is possible, and NO otherwise.

inputFormat

The input consists of a single line containing a binary string \(S\) (a string consisting only of the characters '0' and '1').

outputFormat

Output a single line: YES if the string \(S\) can be converted to a uniform string with at most one flip operation; otherwise, output NO.

## sample
0110
YES