Palindrome

A palindrome is a string that if reversed is equal to the original string. In other words, it is a string that, when read from back to front, is the same as the original string. For example, BANANAB is a palindrome, while BANANAS is not. In this problem we are interested in a more interesting question. Given a string S, we want to find a subsequence that is a palindrome. A subsequence is a string that can be obtained from removing zero or more characters from the original string. For example ANNA is a subsequence of BANANAS. A set of positions of the string S, named special positions, will also be provided. Your task is to find the size of the subsequence that is a palindrome and that includes the largest possible number of special positions. In case there is more than one subsequence that maximizes the number of special positions, you must output the size of the largest subsequence. Input The input consists of several test cases. The first line of a test case contains a string S of capital letters with at least one and at most 2000 letters. The second line will contain an integer number N, 0 ≤ N ≤ |S|, indicating the number of positions that we are interested to include in the palindrome, followed by N different numbers, between 1 and |S|, inclusive, describing the special positions of S. Output For each test case from the input your program should print one unique integer number, representing the size of the biggest possible palindrome, as defined above. Sample Input BANANAS 0 BANANAS 17 ACDAAACX 3238 MARATONA 43152 Sample Output 5 1 3 3