Fedora Project

Generating Palindrome strings

Given a string S, the function replace(a,b) replaces all occurrences of character a with character b in S. For example, if S= "abracadabra", then replace(b,c) gives the string "acracadacra".

A palindrome is a string that reads the same backwards as forwards. For example, "abba" and "dad" are palindromes.

Problem

Write a program that reads a string S and find the minimum number r of applications of the function replace(a,b) to form a palindrome.

Input

A string S that only contains lowercase characters in English.

Output

The value of r. Examples

Input Output croacia 3 dad 0

Task tags

  • python
  • c
  • java
  • c++

Students who completed this task

skr1p7, Rajvardhan, zxyl, rt, weakit, ChrisT, paraxor, dhrug, D3ni, jonot, EmperorAj, Santhu, VH-tech, Angel, Messi rockstar, Andrew Qi Tang, Mukundan314, Ayush19, mbzuk, Plasmatic, chsk kishore, WIndSurfista

Task type

  • code Code
close

2019