Smallest Hamming distance to a palindrome containing a substring This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions


Sensible input: a palindrome exists. This means |A| &ge; |B|.
A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
You may take input from stdin, function arguments, command line arguments, etc.
You may give the result on stdout, return value, etc.
You do not need to give a working palindrome, the smallest distance to one is sufficient.


Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)


Scoring

This is code golf, shortest code in bytes wins.
Pyth, 19 bytes

hSmsnVQd/#z_I#^+Qzl


Demonstration

Extreme brute force approach. Generate all strings of the appropriate length with characters in either string, filter for palindromes and for containing the second input, map to hamming distance from first string, output smallest.

Explanation:

hSmsnVQd/#z_I#^+Qzl
hSmsnVQd/#z_I#^+QzlQ     Variable introduction
                         Q = string A, z = string B.
               +Qz       Concatenate A and B
              ^   lQ     Form every string of length equal to len(A)using
                         characters from the concatenation.
             #           Filter on
           _I            Invariance under reversal (palindrome)
         #               Filter on
        / z              Nonzero occurences of B
  m                      Map to
    nV                   !=, vectorized over
      Qd                 A and the map input
   s                     Sum (gives the hamming weight)
hS                       Min