cswork / OAOpen practice workspace

AmazonOA #248

Is Special Sequence

Estimated MediumJudge-ready

Topics (AI-labelled)HashingPrefix & RangesStrings

Cut a lowercase string into two non-empty contiguous substrings. From each part you may delete at most one character, then rearrange it freely; output YES if both parts can form palindromes, otherwise NO. Deleting is optional, and a part of length 1 can be kept as is.

Input

One line containing the string. 1≤length≤300000, lowercase letters.

Output

Output a single integer, the answer.

Example 1

Input:

abcad

Output:

YES

Example 2

Input:

abcde

Output:

NO

Example 3

Input:

a

Output:

NO

Example notes

The answers are YES, NO and NO. However abcde is split, one of the two parts has at least 3 characters that each occur once, so even after one deletion it cannot be rearranged into a palindrome.

Editorial

Loading solution…