#K49522. Near-Palindrome Checker

    ID: 28661 Type: Default 1000ms 256MiB

Near-Palindrome Checker

Near-Palindrome Checker

You are given a string S consisting of only lowercase English letters. Your task is to determine whether S is a near-palindrome. A string is defined as a near-palindrome if the number of mismatched pairs of characters when comparing the string from the beginning and end is at most one. In mathematical terms, if we compare the characters at positions i and n-i+1 (using 1-indexing), the string is a near-palindrome if

$\text{mismatch} \le 1$

For example, the string "abccba" is a palindrome (0 mismatches) and hence is considered a near-palindrome, while "abcca" has exactly one mismatch and is also a near-palindrome. However, if there are more than one mismatches, the string is not a near-palindrome.

inputFormat

The input consists of a single line that contains the string S with only lowercase English letters.

outputFormat

Output a single line: "YES" if the string is a near-palindrome (has at most one mismatched pair), otherwise output "NO".## sample

abccba
YES