import java.util.* ;
interface alc_tgr {
   static int one(int a, int b, int force, int[] c, String s) {
      if (b - a < 1)
         return 0 ;
      if (c[2*a+force] != 0)
         return c[2*a+force] - 1 ;
      boolean m = (s.charAt(a) == s.charAt(b)) ;
      int r = 1000000 ;
      for (int i=0; i<=2; i++) {
         if ((m == (force == 1) && i == 0) || (m && force == 0 && i == 1))
            continue ;
         if (i >= 1)
            r = Math.min(r, i+one(a+1, b-1, 1, c, s)) ;
         if (i != 1)
            r = Math.min(r, i+one(a+1, b-1, 0, c, s)) ;
      }
      c[2*a+force] = 1 + r ;
      return r ;
   }
   static void main(String[] a) {
      String s = new Scanner(System.in).next() ;
      System.out.println(one(0, s.length()-1, 0, new int[s.length()+5], s)) ;
   }
}
