Problem:
Score : 200 points

Problem Statement

Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.

Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Constraints

S is a string consisting of lowercase English letters.

The length of S is between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

Print the minimum number of hugs needed to make S palindromic.

Sample Input 1

redcoder

Sample Output 1

1

For example, we can change the fourth character to o and get a palindrome redooder.

Sample Input 2

vvvvvv

Sample Output 2

0

We might need no hugs at all.

Sample Input 3

abcdabc

Sample Output 3

2

Solution in Rust (1.15.1) (judge verdict: Runtime Error)

use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let n: String = read();
    let n_char: Vec<char> = n.chars().collect();

    let n_len = n_char.len();
    let mut cnt = 0;

    if n_len % 2 == 1 {
      // 奇数の場合
      let front = &n_char[0..n_len / 2 + 1];
      let back = &n_char[n_len % 2 + 2..];
    
      for (i, v) in front.iter().enumerate() {
        if *v != back[back.len() - i - 1] {
          cnt +=1;
        }
      }
    } else {
      // 偶数の場合
      let front = &n_char[0..n_len / 2];
      let back = &n_char[n_len % 2 + 1..];
    
      for (i, v) in front.iter().enumerate() {
        if *v != back[back.len() - i - 1] {
          cnt +=1;
        }
      }
    }

    println!("{}", cnt)
}