What degree is this palindrome? Your task is to determine the palindromic degree of a given non-empty string.

To do this, loop until one of the following conditions are met:


The string is not a palindrome.
You encounter a string that has already been encountered.


And do the following:


If it is a palindrome, add one to the degree.
Depalindromize.


For example, if I had the string babababab, the calculation would go:

babababab     1
babab         2
bab           3
ba


For the string zzzzz, it would go:

zzzzz         1
zzz           2
zz            3
z             4
z


Test cases

abc 0
cenea 0
pappap 2
aa 2
aba 1
aaa 3
cccc 3
zzzzz 4


Explanation:

abc : 0
cenea : 0
pappap -&gt; pap -&gt; pa : 2
aa -&gt; a -&gt; a : 2
aba -&gt; ab : 1
aaa -&gt; aa -&gt; a -&gt; a: 3
cccc -&gt; cc -&gt; c -&gt; c: 3
zzzzz -&gt; zzz -&gt; zz -&gt; z -&gt; z : 4


Remember, this is code-golf, so the code with the fewest bytes wins.
Perl, 53 bytes
52 bytes of code + 1 byte for -p.
$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{

To run it :
perl -pE '$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{' &lt;&lt;&lt; &quot;zzzzz&quot;