Longest Possible Chunked Palindrome

Given a string, the task is to return the length of its longest possible chunked palindrome. It means a palindrome formed by substrings. For better understanding, look at the examples below.

Examples:

"ghiabcdefhelloadamhelloabcdefghi" should return 7. The palindrome is (ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi).

"merchant" should return 1. The palindrome is (merchant).

Contributed by Berkan Teber