#include <vector>
#include <map>
#include <string>
#include <tuple>

using namespace std;

int N;
char S[50];

map<tuple<int, int, string>, long long> memo;
long long f(int L, int R, string s)
{
	if(s.size() > R-L) 	return 0;
	if(L==R) 			return s.empty();

	auto e = tuple<int, int, string>(L, R, s);
	if(memo.count(e)) 	return memo[e];

	long long v = 0;
	if(!s.empty())
	{
		if(S[L] == s.back())
			v += f(L+1, R, s.substr(0,s.size()-1));
		for(int i=L+1; i<R;++i)
			if(S[L] == S[i])
				v += f(L+1,i,string(S+i+1,S+R)+s);
	}
	else
	{
		for(int i=L+1; i<R;++i)
			if(S[L] == S[i])
				v += 2*f(L+1,i,string(S+i+1,S+R));
	}
	return memo[e]=v;
}


int main() {
	scanf("%d", &N);
	scanf("%s", S);
	printf("%lld\n", f(0,2*N,string()));
}
### Prompt

Develop a solution in CPP to the problem described below:

You are given a string S of length 2N consisting of lowercase English letters.

There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?

* The string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left.

Constraints

* 1 \leq N \leq 18
* The length of S is 2N.
* S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


N
S


Output

Print the number of ways to paint the string that satisfy the condition.

Examples

Input

4
cabaacba


Output

4


Input

11
mippiisssisssiipsspiim


Output

504


Input

4
abcdefgh


Output

0


Input

18
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


Output

9075135300

### Response

```cpp
#include <vector>
#include <map>
#include <string>
#include <tuple>

using namespace std;

int N;
char S[50];

map<tuple<int, int, string>, long long> memo;
long long f(int L, int R, string s)
{
	if(s.size() > R-L) 	return 0;
	if(L==R) 			return s.empty();

	auto e = tuple<int, int, string>(L, R, s);
	if(memo.count(e)) 	return memo[e];

	long long v = 0;
	if(!s.empty())
	{
		if(S[L] == s.back())
			v += f(L+1, R, s.substr(0,s.size()-1));
		for(int i=L+1; i<R;++i)
			if(S[L] == S[i])
				v += f(L+1,i,string(S+i+1,S+R)+s);
	}
	else
	{
		for(int i=L+1; i<R;++i)
			if(S[L] == S[i])
				v += 2*f(L+1,i,string(S+i+1,S+R));
	}
	return memo[e]=v;
}


int main() {
	scanf("%d", &N);
	scanf("%s", S);
	printf("%lld\n", f(0,2*N,string()));
}
```