#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
#define ba 47
#define mo 999999137
#define mod 974711
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
struct Hash {
    char t[20];
    int64 val;
    int len;
    friend bool operator < (const Hash &a,const Hash &b) {
	return a.val < b.val;
    }
    friend bool operator == (const Hash &a,const Hash &b) {
	if(a.val != b.val) return false;
	if(a.len != b.len) return false;
	for(int i = 1 ; i <= a.len ; ++i) {
	    if(a.t[i] != b.t[i]) return false;
	}
	return true;
    }
}B[1000005];
int cnt;
int64 e[55];
struct Mmp {
    struct node {
	int next,v;
	int64 x;
    }E[1000005];
    int head[mod + 5],sumE;
    void clear() {
	memset(head,0,sizeof(head));
	sumE = 0;
    }
    void add(int64 x,int v) {
	int u = x % mod;
	E[++sumE].x = x;
	E[sumE].v = v;
	E[sumE].next = head[u];
	head[u] = sumE;
    }
    void Insert(int64 x) {
	int u = x % mod;
	for(int i = head[u] ; i ; i = E[i].next) {
	    if(E[i].x == x) {E[i].v++;return;}
	}
	add(x,1);
    }
    int Query(int64 x) {
	int u = x % mod;
	for(int i = head[u]; i ; i = E[i].next) {
	    if(E[i].x == x) return E[i].v;
	}
	return 0;
    }
}M1,M2;
int64 Calc(char *s,int l) {
    int64 res = 0;
    for(int i = 1 ; i <= l ; ++i) {
	res += (s[i] - 'a' + 1) * e[i] % mo;
	res %= mo;
    }
    return res;
}
void Insert(char *s,int l) {
    ++cnt;
    for(int i = 1 ; i <= l ; ++i) B[cnt].t[i] = s[i]; 
    B[cnt].len = l;B[cnt].val = Calc(s,l);
}
int N;
char s[55];
void Solve() {
    read(N);
    e[0] = 1;
    for(int i = 1 ; i <= N ; ++i) e[i] = e[i - 1] * ba % mo;
    scanf("%s",s + 1);
    char t1[25],t2[25];
    int c1,c2;
    for(int S = 0 ; S < (1 << N) ; ++S) {
	c1 = c2 = 0;
	int T = 0;
	for(int i = 1 ; i <= N ; ++i) {
	    if(S >> (i - 1) & 1) t1[++c1] = s[i];
	    else {t2[++c2] = s[i];T |= (1 << i - 1);}
	}
	if(S > T) continue;
	if(c1) Insert(t1,c1);
	if(c2) Insert(t2,c2);
    }
    sort(B + 1,B + cnt + 1);
    cnt = unique(B + 1,B + cnt + 1) - B - 1;
    M1.clear();M2.clear();
    for(int i = 1 ; i <= cnt ; ++i) {
	M1.add(B[i].val,i);
    }
    for(int S = 0 ; S < (1 << N) ; ++S) {
	c1 = c2 = 0;
	for(int i = 1 ; i <= N ; ++i) {
	    if(S >> (i - 1) & 1)  t1[++c1] = s[i];
	    else {t2[++c2] = s[i];}
	}
	int d1 = 0,d2 = 0;
	if(c1) d1 = M1.Query(Calc(t1,c1));
	if(c2) d2 = M1.Query(Calc(t2,c2));
	M2.Insert(1LL * d1 * (cnt + 1) + d2);
    }
    int64 ans = 0;
    for(int S = 0 ; S < (1 << N) ; ++S) {
	c1 = c2 = 0;
	for(int i = N + 1 ; i <= 2 * N ; ++i) {
	    if(S >> (i - N - 1) & 1) t1[++c1] = s[i];
	    else {t2[++c2] = s[i];}
	}
	reverse(t1 + 1,t1 + c1 + 1);
	reverse(t2 + 1,t2 + c2 + 1);
	int d1 = 0,d2 = 0;
	if(c1) d1 = M1.Query(Calc(t1,c1));
	if(c2) d2 = M1.Query(Calc(t2,c2));
	ans += M2.Query(1LL * d1 * (cnt + 1) + d2);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 30976