from collections import *



N = int(eval(input()))

s = list(eval(input()))

cnt = defaultdict(lambda : defaultdict(int))



for S in range(2**N):

    red, blue = [], []

    

    for i in range(N):

        if (S>>i)&1:

            red.append(s[i])

        else:

            blue.append(s[i])

    

    cnt[''.join(red)][''.join(blue)] += 1



s.reverse()

ans = 0



for S in range(2**N):

    red, blue = [], []

    

    for i in range(N):

        if (S>>i)&1:

            red.append(s[i])

        else:

            blue.append(s[i])

    

    ans += cnt[''.join(blue)][''.join(red)]



print(ans)
import sys

input = sys.stdin.readline

from collections import *



N = int(eval(input()))

s = input()[:-1]

cnt = defaultdict(int)



for S in range(1<<N):

    red, blue = [], []

    

    for i in range(N):

        if (S>>i)&1:

            red.append(s[i])

        else:

            blue.append(s[i])

    

    cnt[(''.join(red), ''.join(blue))] += 1



s = s[::-1]

ans = 0



for S in range(1<<N):

    red, blue = [], []

    

    for i in range(N):

        if (S>>i)&1:

            red.append(s[i])

        else:

            blue.append(s[i])

    

    ans += cnt[(''.join(blue), ''.join(red))]



print(ans)
from collections import *

N = int(eval(input()))
s = list(eval(input()))
cnt = defaultdict(lambda: defaultdict(int))
for S in range(2**N):
    red, blue = [], []
    for i in range(N):
        if (S >> i) & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    cnt["".join(red)]["".join(blue)] += 1
s.reverse()
ans = 0
for S in range(2**N):
    red, blue = [], []
    for i in range(N):
        if (S >> i) & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    ans += cnt["".join(blue)]["".join(red)]
print(ans)

import sys

input = sys.stdin.readline
from collections import *

N = int(eval(input()))
s = input()[:-1]
cnt = defaultdict(int)
for S in range(1 << N):
    red, blue = [], []
    for i in range(N):
        if (S >> i) & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    cnt[("".join(red), "".join(blue))] += 1
s = s[::-1]
ans = 0
for S in range(1 << N):
    red, blue = [], []
    for i in range(N):
        if (S >> i) & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    ans += cnt[("".join(blue), "".join(red))]
print(ans)

+import sys + +input = sys.stdin.readline -s = list(eval(input())) -cnt = defaultdict(lambda: defaultdict(int)) -for S in range(2**N): +s = input()[:-1] +cnt = defaultdict(int) +for S in range(1 << N): -    cnt["".join(red)]["".join(blue)] += 1 -s.reverse() +    cnt[("".join(red), "".join(blue))] += 1 +s = s[::-1] -for S in range(2**N): +for S in range(1 << N): -    ans += cnt["".join(blue)]["".join(red)] +    ans += cnt[("".join(blue), "".join(red))]