Brachylog, 1010 9 bytes
-1 byte thanks to a clever observation from Unrelated String
↔?ḍt↰+₁|∧0ḍt↰<|∧0 Alternate 109-byte solution: ↔?ḍt↰+₁ḍt↰<.∨0 (Try it online!Try it online!)
Explanation
↔?ḍt↰+₁|∧0ḍt↰<|∧0 ↔ The input reversed ? is the same as the input ḍ Split into two halves t Take the second half (which is the longer one if they aren't the same) ↰ Recurse +₁< AddFirst 1integer togreater than the result of the recursive call | If the preceding part failed (because the input isn't a palindrome): ∧ Break unification with the input 0 and set the output to 0