1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    
    int l = (int)s.size() - 1;
    int cal = 0;
    int w = 0;
    for (int i = 0; i < (l + 1) / 2;i++)
    {
        if (s[i] != s[l - i])

            cal++;
    }
  if (cal % 2 != 0)
  {
      cal++;
      
      if (l %2 != 0)
      {
          cout << -1;
          return 0;
      }
  }

    cout << cal/2;
    return 0;
}