#include <bits/stdc++.h> 
using namespace std;

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 41;
int const MOD1 = 1000003241;
int const MOD2 = 1000000403;

int const P = 41;

map<pii, ll> d1[MAX][MAX];
map<pii, ll> d2[MAX][MAX];

int n;
char s[MAX];
ll ans;
int p1[MAX];

int add(int a, int b, int MOD) {
	return (a + b) % MOD;
}

int sub(int a, int b, int MOD) {
	a -= b;
	a %= MOD;
	if (a < 0) a += MOD;
	return a;
}

int mult(int a, int b, int MOD) {
	return (ll) a * b % MOD;
}

bool bit(int m, int i) {
	return (1 & (m >> i));
}

int p2[MAX];

void solve() {
	p1[0] = 1;
	p2[0] = 1;
	fi(1, MAX - 1) {
		p1[i] = mult(p1[i - 1], P, MOD1);
		p2[i] = mult(p2[i - 1], P, MOD2);
	}

	for (int mask = 0; mask < (1 << n); mask++) {
		string r, b;
		fi(0, n - 1) {
			if (bit(mask, i)) {
				r += s[i + 1];
			} else {
				b += s[i + 1];
			}
		}				
		pii hr = mp(0, 0);
		fi(0, sz(r) - 1) {
			int v1 = mult(r[i] - 'a', p1[i], MOD1);
			int v2 = mult(r[i] - 'a', p2[i], MOD2);

			hr.first = add(hr.first, v1, MOD1);
			hr.second = add(hr.second, v2, MOD2);
		}

		pii hb = mp(0, 0);
		fi(0, sz(b) - 1) {
			int v1 = mult(b[i] - 'a', p1[n - 1 - i], MOD1);
			int v2 = mult(b[i] - 'a', p2[n - 1 - i], MOD2);
			
			hb.first = add(hb.first, v1, MOD1);
			hb.second = add(hb.second, v2, MOD2);

		}
		pii diff = mp(sub(hr.first, hb.first, MOD1), sub(hr.second, hb.second, MOD2));
		d1[sz(r)][sz(b)][diff]++;
	}

	for (int mask = 0; mask < (1 << n); mask++) {
		string r, b;
		fi(0, n - 1) {
			if (bit(mask, i)) {
				r += s[i + 1 + n];
			} else {
				b += s[i + 1 + n];
			}
		}				
		pii hr = mp(0, 0);
		fi(0, sz(r) - 1) {
			int v1 = mult(r[i] - 'a', p1[i + n - sz(r)], MOD1);
			int v2 = mult(r[i] - 'a', p2[i + n - sz(r)], MOD2);

			hr.first = add(hr.first, v1, MOD1);
			hr.second = add(hr.second, v2, MOD2);
		}

		pii hb = mp(0, 0);
		fdi(sz(b) - 1, 0) {
			int v1 = mult(b[i] - 'a', p1[sz(b) - 1 - i], MOD1);
			int v2 = mult(b[i] - 'a', p2[sz(b) - 1 - i], MOD2);
			
			hb.first = add(hb.first, v1, MOD1);
			hb.second = add(hb.second, v2, MOD2);
		}
		pii diff = mp(sub(hb.first, hr.first, MOD1), sub(hb.second, hr.second, MOD2));
		d2[sz(r)][sz(b)][diff]++;
	}

//	err("size 1 = %d size 2  = %d\n", sz(d1), sz(d2));

	fi(0, n) {
		fj(0, n) {
			for (auto z : d1[i][j]) {
				if (d2[n - i][n - j].find(z.first) != d2[n - i][n - j].end()) {
					ans += z.second * d2[n - i][n - j][z.first];
				}
			}
		}
	}

	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	scanf(" %s", s + 1);
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 33152