program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: i,j,n,ans,tmp
    integer(int64):: cnt(ichar('a'):ichar('z'))
    character(100000):: s

    read*, n
    read*, s
    cnt(:) = 0
    do i=1,n
        cnt(ichar(s(i:i)))=cnt(ichar(s(i:i)))+1
    end do

    ans=0
    do i=0,2**26-1
        tmp=0
        do j=ichar('a'),ichar('z')
            if (btest(i,j-ichar('a'))) tmp=max(tmp,1_8)*cnt(j)
        end do
        ans=ans+tmp
    end do

    print'(i0)', ans
end program name