You are given a binary string and distinct indices to perform an operation.
The operation is like below:
You can shuffle the given indices any number of times (possibly zero).
You have to find out the maximum length of a palindromic subsequence of string after shuffling.
Example of an operation: Say = “001110”, Let the indices be . Then after the operation the string content can be, 100110.
The first line of input contains a string and an integer
The next line will contain space separated integers denoting the indices that you can shuffle, all of them are guaranteed to be distinct.
Output one line containing the output, the maximum length of any palindromic subsequence after the operation.
Input | Output |
---|---|
10010 2 1 2 | 5 |