def t():

    n=int(eval(input()))

    s=eval(input())

    from collections import defaultdict

    l,r=s[:n],s[-1:-n-1:-1]

    d=defaultdict(int)

    for i in range(2**n):

        a={j for j in range(n)if (i>>j)%2}

        d[("".join(l[p] for p in sorted(list(a))),"".join(l[o] for o in range(n)if o not in a))]+=1

    ans=0

    for i in range(2**n):

        a={j for j in range(n)if (i>>j)%2}

        ans+=d[("".join(r[p] for p in sorted(list(a))),"".join(r[o] for o in range(n)if o not in a))]



    print(ans)

if __name__ == "__main__":

    t()
def f():

    n,s=int(eval(input())),eval(input())

    a,b=s[n-1::-1],s[n:]

    from collections import defaultdict

    ad=defaultdict(int)

    bd=defaultdict(int)

    for i in range(2**n):

        sa,ta,sb,tb="","","",""

        for j in range(n):

            if i%2:

                sa+=a[j]

                sb+=b[j]

            else:

                ta+=a[j]

                tb+=b[j]

            i//=2

        ad[(sa,ta)]+=1

        bd[(sb,tb)]+=1

    ans=0

    for k in ad:

        ans+=bd[k]*ad[k]

    print(ans)

if __name__ == "__main__":

    f()

def t():
    n = int(eval(input()))
    s = eval(input())
    from collections import defaultdict

    l, r = s[:n], s[-1 : -n - 1 : -1]
    d = defaultdict(int)
    for i in range(2**n):
        a = {j for j in range(n) if (i >> j) % 2}
        d[
            (
                "".join(l[p] for p in sorted(list(a))),
                "".join(l[o] for o in range(n) if o not in a),
            )
        ] += 1
    ans = 0
    for i in range(2**n):
        a = {j for j in range(n) if (i >> j) % 2}
        ans += d[
            (
                "".join(r[p] for p in sorted(list(a))),
                "".join(r[o] for o in range(n) if o not in a),
            )
        ]
    print(ans)


if __name__ == "__main__":
    t()

def f():
    n, s = int(eval(input())), eval(input())
    a, b = s[n - 1 :: -1], s[n:]
    from collections import defaultdict

    ad = defaultdict(int)
    bd = defaultdict(int)
    for i in range(2**n):
        sa, ta, sb, tb = "", "", "", ""
        for j in range(n):
            if i % 2:
                sa += a[j]
                sb += b[j]
            else:
                ta += a[j]
                tb += b[j]
            i //= 2
        ad[(sa, ta)] += 1
        bd[(sb, tb)] += 1
    ans = 0
    for k in ad:
        ans += bd[k] * ad[k]
    print(ans)


if __name__ == "__main__":
    f()

-def t(): -    n = int(eval(input())) -    s = eval(input()) +def f(): +    n, s = int(eval(input())), eval(input()) +    a, b = s[n - 1 :: -1], s[n:] -    l, r = s[:n], s[-1 : -n - 1 : -1] -    d = defaultdict(int) +    ad = defaultdict(int) +    bd = defaultdict(int) -        a = {j for j in range(n) if (i >> j) % 2} -        d[ -            ( -                "".join(l[p] for p in sorted(list(a))), -                "".join(l[o] for o in range(n) if o not in a), -            ) -        ] += 1 +        sa, ta, sb, tb = "", "", "", "" +        for j in range(n): +            if i % 2: +                sa += a[j] +                sb += b[j] +            else: +                ta += a[j] +                tb += b[j] +            i //= 2 +        ad[(sa, ta)] += 1 +        bd[(sb, tb)] += 1 -    for i in range(2**n): -        a = {j for j in range(n) if (i >> j) % 2} -        ans += d[ -            ( -                "".join(r[p] for p in sorted(list(a))), -                "".join(r[o] for o in range(n) if o not in a), -            ) -        ] +    for k in ad: +        ans += bd[k] * ad[k] -    t() +    f()