Here is the problem:

A sequence of letters of the form abcba is an example of a palindrome of five letters.

a. If a letter may appear more than twice, how many palindromes of five letters are there? of six letters?

b. Repeat part a under the condition that no letter appears more than twice.

I do not know how to go about doing this problem. Any help would be appreciated. thanks.