//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dp[20][(1<<20)+1];
int cac[20][20];
int n,d;

int mask=0;

int sol(int po,int mask)
{
	if(po==d)
	return 0;

	int &x=dp[po][mask];
	if(x!=-1)
	return x;

	x=ima;

	for(int i=0;i<d;i++)
	{
		if(mask&(1<<i))
			continue;

		int cos=0;
		for(int j=0;j<d;j++)
		{
			if(mask&(1<<j))
			cos+=(cac[i][j]*(po));
			else
			cos+=(cac[i][j]*(-po));
		}

		x=min(x,cos+sol(po+1,mask|(1<<i)));

	}

	return x;

}

int main()
{       io
int testcases=1;      //       cin>>testcases;
while(testcases--)
{

cin>>n>>d;
string s;
cin>>s;

for(int i=0;i<d;i++)
{
	for(int j=0;j<=(1<<d);j++)
	dp[i][j]=-1;

}

for(int i=0;i<d;i++)
{
	for(int j=0;j<d;j++)
	cac[i][j]=0;
}

for(int i=0;i<n-1;i++)
{
	int a=int(s[i])-97;
	int b=int(s[i+1])-97;
	if(a!=b)
	{cac[a][b]++;
	cac[b][a]++;
	}
}

cout<<sol(0,mask);

 /*
 2 2
 ab
 */

}return 0;}


//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll dp[20][(1<<20)+2];
ll cac[21][21];
int n,d;

int mask=0;

ll sol(int po,int mask)
{
	if(po==d)
	return 0;

	ll &x=dp[po][mask];
	if(x!=-1)
	return x;

	x=inf;

	for(int i=0;i<d;i++)
	{
		if(mask&(1<<i))
			continue;

		ll cos=0;
		for(int j=0;j<d;j++)
		{
			if(mask&(1<<j))
			cos+=(cac[i][j]*(po));
			else
			cos+=(cac[i][j]*(-po));
		}

		x=min(x,cos+sol(po+1,mask|(1<<i)));

	}

	return x;

}

int main()
{       io
int testcases=1;      //       cin>>testcases;
while(testcases--)
{

mems(dp,-1);
for(int i=0;i<d;i++)
{
	for(int j=0;j<d;j++)
	cac[i][j]=0;
}

cin>>n>>d;
string s;
cin>>s;

for(int i=0;i<n-1;i++)
{
	int a=int(s[i])-97;
	int b=int(s[i+1])-97;
	if(a!=b)
	{cac[a][b]++;
	cac[b][a]++;
	}
}

cout<<sol(0,mask);

 /*
 2 2
 ab
 */

}return 0;}


//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll dp[20][(1<<20)+2];
ll cac[21][21];
int n,d;

int mask=0;

ll sol(int po,int mask)
{
	if(po==d)
	return 0;

	ll &x=dp[po][mask];
	if(x!=-1)
	return x;

	x=inf;

	for(int i=0;i<d;i++)
	{
		if(mask&(1<<i))
			continue;

		ll cos=0;
		for(int j=0;j<d;j++)
		{
			if(mask&(1<<j))
			cos+=(cac[i][j]*(po));
			else
			cos+=(cac[i][j]*(-po));
		}

		x=min(x,cos+sol(po+1,mask|(1<<i)));

	}

	return x;

}

int main()
{       io
int testcases=1;      //       cin>>testcases;
while(testcases--)
{

mems(dp,-1);
for(int i=0;i<d;i++)
{
	for(int j=0;j<d;j++)
	cac[i][j]=0;
}

cin>>n>>d;
string s;
cin>>s;

for(int i=0;i<n-1;i++)
{
	int a=int(s[i])-97;
	int b=int(s[i+1])-97;

	cac[a][b]++;
	cac[b][a]++;
}

cout<<sol(0,mask)<<"\n";

 /*
 2 2
 ab
 */

}return 0;}


//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll dp[20][(1<<20)+2];
ll cac[21][21];
int n,d;

int mask=0;

ll sol(int po,int mask)
{
	if(po==d)
	return 0;

	ll &x=dp[po][mask];
	if(x!=-1)
	return x;

	x=inf;

	for(int i=0;i<d;i++)
	{
		if(mask&(1<<i))
			continue;

		ll cos=0;
		for(int j=0;j<d;j++)
		{
			if(mask&(1<<j))
			cos+=(cac[i][j]*(po));
			else
			cos+=(cac[i][j]*(-po));
		}

		x=min(x,cos+sol(po+1,mask|(1<<i)));

	}

	return x;

}

int main()
{       io
int testcases=1;      //       cin>>testcases;
while(testcases--)
{

for(int i=0;i<d;i++)
{
	for(int j=0;j<=(1<<d);j++)
	dp[i][j]=-1;

}

for(int i=0;i<d;i++)
{
	for(int j=0;j<d;j++)
	cac[i][j]=0;
}

cin>>n>>d;
string s;
cin>>s;

for(int i=0;i<n-1;i++)
{
	int a=int(s[i])-97;
	int b=int(s[i+1])-97;
	if(a!=b)
	{cac[a][b]++;
	cac[b][a]++;
	}
}

cout<<sol(0,mask);

 /*
 2 2
 ab
 */

}return 0;}


//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll dp[20][(1<<20)+2];
ll cac[21][21];
int n,d;

int mask=0;

ll sol(int po,int mask)
{
	if(po==d)
	return 0;

	ll &x=dp[po][mask];
	if(x!=-1)
	return x;

	x=inf;

	for(int i=0;i<d;i++)
	{
		if(mask&(1<<i))
			continue;

		ll cos=0;
		for(int j=0;j<d;j++)
		{
			if(mask&(1<<j))
			cos+=(cac[i][j]*(po));
			else
			cos+=(cac[i][j]*(-po));
		}

		x=min(x,cos+sol(po+1,mask|(1<<i)));

	}

	return x;

}

int main()
{       io
int testcases=1;      //       cin>>testcases;
while(testcases--)
{

cin>>n>>d;
string s;
cin>>s;

for(int i=0;i<d;i++)
{
	for(int j=0;j<=(1<<d);j++)
	dp[i][j]=-1;

}

for(int i=0;i<d;i++)
{
	for(int j=0;j<d;j++)
	cac[i][j]=0;
}

for(int i=0;i<n-1;i++)
{
	int a=int(s[i])-97;
	int b=int(s[i+1])-97;
	if(a!=b)
	{cac[a][b]++;
	cac[b][a]++;
	}
}

cout<<sol(0,mask);

 /*
 2 2
 ab
 */

}return 0;}


#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int cost[20][20];
int dp[20][1 << 20], dq[1 << 20];
int n, m;

int f(int k, int mask)
{
    if (k == m)
        return 0;
    if (dp[k][mask] != -1)
        return dp[k][mask];

    int sol = 1e9;
    for (int i = 0; i < m; ++i)
        if (!(mask & (1 << i)))
            sol = min(sol, dq[mask | (1 << i)] + f(k + 1, mask | (1 << i)));

    return dp[k][mask] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    for (int i = 1; i < n; ++i)
    {
        int a = s[i] - 'a';
        int b = s[i - 1] - 'a';
        cost[a][b]++;
        cost[b][a]++;
    }
    for (int mask = 0; mask < (1 << m); ++mask)
    {
        for (int i = 0; i < m; ++i)
        {
            if (!(mask & (1 << i))) continue;
            for (int j = 0; j < m; ++j)
                if (!(mask & (1 << j)))
                    dq[mask] += cost[i][j];
        }
    }
    memset(dp, -1, sizeof dp);
    cout << f(0, 0);
}


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

int n, m, cost[20][20], dp[1 << 20], dq[1 << 20];

int ctz(int x) { return __builtin_ctz(x); }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    for (int i = 1; i < n; ++i)
    {
        int a = s[i] - 'a';
        int b = s[i - 1] - 'a';
        cost[a][b]++;
        cost[b][a]++;
    }

    int full = (1 << m) - 1;
    for (int mask = 0; mask < (1 << m); ++mask)
        for (int mi = mask; mi; mi -= (mi & -mi))
            for (int mj = full - mask; mj; mj -= (mj & -mj))
                dq[mask] += cost[ctz(mi)][ctz(mj)];

    dp[full] = 0;
    for (int mask = full - 1; mask >= 0; --mask)
    {
        dp[mask] = 1e9;
        for (int mi = full - mask; mi; mi -= (mi & -mi))
            dp[mask] = min(dp[mask], dq[mask | (mi & -mi)] + dp[mask | (mi & -mi)]);
    }

    cout << dp[0];
}


#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
using namespace std;

int n, m, cost[20][20], dp[1 << 20], dq[1 << 20];

int ctz(int x) { return __builtin_ctz(x); }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    for (int i = 1; i < n; ++i)
    {
        int a = s[i] - 'a';
        int b = s[i - 1] - 'a';
        cost[a][b]++;
        cost[b][a]++;
    }

    int full = (1 << m) - 1;
    for (int mask = 0; mask < (1 << m); ++mask)
        for (int mi = mask; mi; mi -= (mi & -mi))
            for (int mj = full - mask; mj; mj -= (mj & -mj))
                dq[mask] += cost[ctz(mi)][ctz(mj)];

    dp[full] = 0;
    for (int mask = full - 1; mask >= 0; --mask)
    {
        dp[mask] = 1e9;
        for (int mi = full - mask; mi; mi -= (mi & -mi))
            dp[mask] = min(dp[mask], dq[mask | (mi & -mi)] + dp[mask | (mi & -mi)]);
    }

    cout << dp[0];
}


#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int cost[20][20];
int dp[1 << 20], dq[1 << 20];
int n, m;

int ctz(int x)
{
    return __builtin_ctz(x);
}

int f(int mask)
{
    int k = __builtin_popcount(mask);
    if (k == m)
        return 0;
    if (dp[mask] != -1)
        return dp[mask];

    int sol = 1e9;
    for (int i = 0; i < m; ++i)
        if (!(mask & (1 << i)))
            sol = min(sol, dq[mask | (1 << i)] + f(mask | (1 << i)));

    return dp[mask] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    for (int i = 1; i < n; ++i)
    {
        int a = s[i] - 'a';
        int b = s[i - 1] - 'a';
        cost[a][b]++;
        cost[b][a]++;
    }

    int full = (1 << m) - 1;
    for (int mask = 0; mask < (1 << m); ++mask)
        for (int mi = mask; mi; mi -= (mi & -mi))
            for (int mj = full - mask; mj; mj -= (mj & -mj))
                dq[mask] += cost[ctz(mi)][ctz(mj)];

    memset(dp, -1, sizeof dp);
    cout << f(0);
}


#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int cost[20][20];
int dp[1 << 20], dq[1 << 20];
int n, m;

int f(int mask)
{
    int k = __builtin_popcount(mask);
    if (k == m)
        return 0;
    if (dp[mask] != -1)
        return dp[mask];

    int sol = 1e9;
    for (int i = 0; i < m; ++i)
        if (!(mask & (1 << i)))
            sol = min(sol, dq[mask | (1 << i)] + f(mask | (1 << i)));

    return dp[mask] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    for (int i = 1; i < n; ++i)
    {
        int a = s[i] - 'a';
        int b = s[i - 1] - 'a';
        cost[a][b]++;
        cost[b][a]++;
    }
    for (int mask = 0; mask < (1 << m); ++mask)
    {
        for (int i = 0; i < m; ++i)
        {
            if (!(mask & (1 << i))) continue;
            for (int j = 0; j < m; ++j)
                if (!(mask & (1 << j)))
                    dq[mask] += cost[i][j];
        }
    }
    memset(dp, -1, sizeof dp);
    cout << f(0);
}


/**
 *    author:  MySakure
 *    created: 13.10.2019 13:30:03
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int n,m,dp[(1<<20)],cnt[30][30],a[maxn];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef mysakure
	freopen("in1.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		char tmp;
		cin>>tmp;
		a[i]=tmp-'a';
	}
	for(int i=1;i<n;++i){
		if(a[i]==a[i+1])continue;
		cnt[a[i]][a[i+1]]++;
		cnt[a[i+1]][a[i]]++;
	}
	fill(dp+1, dp+(1<<m), INT_MAX);
	for(int i=0;i<(1<<m)-1;++i){
		int c = __builtin_popcount(i);
		for(int j=0;j<m;++j){
			if(i&(1<<j))continue;
			int res=dp[i];
			for(int k=0;k<m;++k){
				if(i&(1<<k))res+=cnt[j][k]*c;
				else res-=cnt[j][k]*c;
			}
			dp[i|(1<<j)]=min(dp[i|(1<<j)],res);
		}
	}
	cout<<dp[(1<<m)-1]<<'\n';
	return 0;
}


/**
 *    author:  MySakure
 *    created: 13.10.2019 13:30:03
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int n,m,dp[(1<<20)],cnt[30][30],a[maxn];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef mysakure
	freopen("in3.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		char tmp;
		cin>>tmp;
		a[i]=tmp-'a';
	}
	for(int i=1;i<n;++i){
		if(a[i]==a[i+1])continue;
		cnt[a[i]][a[i+1]]++;
		cnt[a[i+1]][a[i]]++;
	}
	fill(dp+1, dp+(1<<m), INT_MAX);
	for(int i=0;i<(1<<m)-1;++i){
		int c = __builtin_popcount(i);
		for(int j=0;j<m;++j){
			if(i&(1<<j))continue;
			int res=dp[i];
			for(int k=0;k<m;++k){
				if(i&(1<<k))res-=cnt[j][k]*c;
				else res+=cnt[j][k]*c;
			}
			dp[i|(1<<j)]=min(dp[i|(1<<j)],res);
		}
	}
	cout<<dp[(1<<m)-1]<<'\n';

	return 0;
}


/**
 *    author:  MySakure
 *    created: 13.10.2019 13:30:03
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int n,m,dp[(1<<20)],cnt[20][20],a[maxn];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef mysakure
	freopen("in1.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		char tmp;
		cin>>tmp;
		a[i]=tmp-'a';
	}
	for(int i=1;i<n;++i){
		if(a[i]==a[i+1])continue;
		cnt[a[i]][a[i+1]]++;
		cnt[a[i+1]][a[i]]++;
	}
	fill(dp+1, dp+(1<<m), INT_MAX);
	for(int i=0;i<(1<<m)-1;++i){
		int c = __builtin_popcount(i);
		for(int j=0;j<m;++j){
			if(i&(1<<j))continue;
			int res=dp[i];
			for(int k=0;k<m;++k){
				if(i&(1<<k))res+=cnt[j][k]*c;
				else res-=cnt[j][k]*c;
			}
			dp[i|(1<<j)]=min(dp[i|(1<<j)],res);
		}
	}
	cout<<dp[(1<<m)-1]<<'\n';
	return 0;
}


/**
 *    author:  MySakure
 *    created: 13.10.2019 13:30:03
**/
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,dp[(1<<20)],cnt[20][20],a[maxn];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef mysakure
	freopen("in1.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		char tmp;
		cin>>tmp;
		a[i]=tmp-'a';
	}
	for(int i=1;i<n;++i){
		if(a[i]==a[i+1])continue;
		cnt[a[i]][a[i+1]]++;
		cnt[a[i+1]][a[i]]++;
	}
	fill(dp+1, dp+(1<<m), INT_MAX);
	for(int i=0;i<(1<<m)-1;++i){
		int c = __builtin_popcount(i);
		for(int j=0;j<m;++j){
			if(i&(1<<j))continue;
			int res=dp[i];
			for(int k=0;k<m;++k){
				if(i&(1<<k))res+=cnt[j][k]*c;
				else res-=cnt[j][k]*c;
			}
			dp[i|(1<<j)]=min(dp[i|(1<<j)],res);
		}
	}
	cout<<dp[(1<<m)-1]<<'\n';
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const int M=20;
    int dp[1<<M];
    int m;
    int cnt[M][M];
int solve(int mask)
{
    //trace(mask);
    int &res=dp[mask];
    if(res!=-1)
    {

        return res;
    }
    if(mask==0LL)
        return 0LL;
    res=mod;
    for(int i=0;i<m;i++)
    {
        if(mask&(1LL<<i))
        {
            int pos=__builtin_popcount(mask);
            //trace(pos);
            int cost=0;
            for(int j=0;j<m;j++)
            {
                if(j==i)
                    continue;
                if((mask>>j)&(1LL))
                {
                    cost+=pos*cnt[i][j];
                }
                else
                    cost-=pos*cnt[i][j];
            }
            //trace(cost);
            res=min(res,solve(mask^(1LL<<i))+cost);
        }
    }
    return res;
}
int main()
{
   #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif
  IOS
  memset(dp,-1,sizeof(dp));
  int n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(int i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(int i=0;i<m;i++,cout<<endl)
    for(int j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  int ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const ll M=20;
    ll dp[1<<M];
    ll m;
    ll cnt[M][M];
ll solve(ll mask)
{
    //trace(mask);
    ll &res=dp[mask];
    if(res!=-1)
    {
        return res;
    }
    if(mask==0LL||__builtin_popcount(mask)==0LL)
        return res=0LL;
    res=mod;
    for(ll i=0;i<m;i++)
    {
        if(mask&(1LL<<i))
        {
            ll pos=__builtin_popcount(mask);
            ll cost=0;
            for(ll j=0;j<m;j++)
            {

                if(!((mask>>j)&(1LL)))
                {
                    cost+=pos*cnt[i][j];
                }

            }
            res=min(res,solve(mask^(1LL<<i)));
        }
    }
    res+=cost;

    return res;
}
int main()
{
 /*  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif*/
  IOS
  memset(dp,-1,sizeof(dp));
  ll n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(ll i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(ll i=0;i<m;i++,cout<<endl)
    for(ll j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  ll ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const ll M=20;
    ll dp[1<<M];
    ll m;
    ll cnt[M][M];
ll solve(ll mask)
{
    //trace(mask);
    ll &res=dp[mask];
    if(res!=-1)
    {
        return res;
    }
    if(mask==0LL||__builtin_popcount(mask)==0LL)
        return res=0LL;
    res=mod;
    ll cost=0;
    for(ll i=0;i<m;i++)
    {
        if(mask>>i&(1LL))
        {
            ll pos=__builtin_popcount(mask);

            for(ll j=0;j<m;j++)
            {

                if(((mask>>j)&(1LL))==0LL)
                {
                    cost+=cnt[i][j];
                }

            }
            res=min(res,solve(mask^(1LL<<i)));
        }
    }
    res+=cost;

    return res;
}
int main()
{
   #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif
  IOS
  memset(dp,-1,sizeof(dp));
  ll n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(ll i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(ll i=0;i<m;i++,cout<<endl)
    for(ll j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  ll ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const ll M=20;
    ll dp[1<<M];
    ll m;
    ll cnt[M][M];
ll solve(ll mask)
{
    //trace(mask);
    ll &res=dp[mask];
    if(res!=-1)
    {
        return res;
    }
    if(mask==0LL||__builtin_popcount(mask)==0LL)
        return res=0LL;
    res=mod;
    for(ll i=0;i<m;i++)
    {
        if(mask&(1LL<<i))
        {
            ll pos=__builtin_popcount(mask);
            ll cost=0;
            for(ll j=0;j<m;j++)
            {
                if(j==i)
                    continue;
                if((mask>>j)&(1LL))
                {
                    cost+=pos*cnt[i][j];
                }
                else
                    cost-=pos*cnt[i][j];
            }
            res=min(res,solve(mask^(1LL<<i))+cost);
        }
    }

    return res;
}
int main()
{
 /*  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif*/
  IOS
  memset(dp,-1,sizeof(dp));
  ll n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(ll i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(ll i=0;i<m;i++,cout<<endl)
    for(ll j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  ll ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const ll M=20;
    ll dp[1<<M];
    ll m;
    ll cnt[M][M];
ll solve(ll mask)
{
    //trace(mask);
    ll &res=dp[mask];
    if(res!=-1)
    {
        return res;
    }
    if(mask==0LL||__builtin_popcount(mask)==0LL)
        return res=0LL;
    res=mod;
    ll cost=0;
    for(ll i=0;i<m;i++)
    {
        if(mask&(1LL<<i))
        {
            ll pos=__builtin_popcount(mask);

            for(ll j=0;j<m;j++)
            {

                if(!((mask>>j)&(1LL)))
                {
                    cost+=pos*cnt[i][j];
                }

            }
            res=min(res,solve(mask^(1LL<<i)));
        }
    }
    res+=cost;

    return res;
}
int main()
{
 /*  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif*/
  IOS
  memset(dp,-1,sizeof(dp));
  ll n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(ll i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(ll i=0;i<m;i++,cout<<endl)
    for(ll j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  ll ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
    const ll M=20;
    ll dp[1<<M];
    ll m;
    ll cnt[M][M];
ll solve(ll mask)
{
    //trace(mask);
    ll &res=dp[mask];
    if(res!=-1)
    {

        return res;
    }
    if(mask==0LL)
        return 0LL;
    res=mod;
    for(ll i=0;i<m;i++)
    {
        if(mask&(1LL<<i))
        {
            ll pos=__builtin_popcount(mask);
            //trace(pos);
            ll cost=0;
            for(ll j=0;j<m;j++)
            {
                if(j==i)
                    continue;
                if((mask>>j)&(1LL))
                {
                    cost+=pos*cnt[i][j];
                }
                else
                    cost-=pos*cnt[i][j];
            }
            //trace(cost);
            res=min(res,solve(mask^(1LL<<i))+cost);
        }
    }
    return res;
}
int main()
{
   #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif
  IOS
  memset(dp,-1,sizeof(dp));
  ll n;
  cin>>n>>m;
  string s;
  cin>>s;

  memset(cnt,0,sizeof(cnt));
  for(ll i=1;i<n;i++)
  {
    cnt[s[i]-'a'][s[i-1]-'a']++;
    cnt[s[i-1]-'a'][s[i]-'a']++;
  }
  /*for(ll i=0;i<m;i++,cout<<endl)
    for(ll j=0;j<m;j++)
        cout<<cnt[i][j]<<" ";
*/  ll ans=solve((1LL<<m)-1);
  cout<<ans<<endl;

}


#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

bool codejam = 0;

int n,m;
string s;

int cnt[26][26];
vector<int> dp((1<<20),INF);

void solve()
{
    cin>>n>>m;
    cin>>s;

    for(int i=1;i<n;i++){
        if(s[i] < s[i-1])
            cnt[s[i]-'a'][s[i-1]-'a'] += 1;
        else
            cnt[s[i-1]-'a'][s[i]-'a'] += 1;
    }

    dp[0] = 0;
    int cur = 0;
    for(int i=0;i<(1<<m);i++){
        cur = __builtin_popcountll(i);
        // cout<<cur;
        for(int j=0;j<m;j++){
            int add = 0;
            if( (i & (1<<j))){
                for(int k=0;k<m;k++){

                    if(j == k) continue;

                    if( (i & (1<<k)) )
                        add +=cnt[min(j,k)][max(j,k)];
                    else
                        add -=cnt[min(j,k)][max(j,k)];
                }
            }
            dp[i] = min(dp[i],dp[i^(1<<j)] + (cur+1)*add);
        }

    }
    // for(int i=0;i<(1<<m);i++){
    //     tr(i,dp[i]);
    // }
    cout<<dp[(1<<m)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}


#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

int cnt[26][26];
vector<int> dp((1<<m),INF);

void solve()
{
    cin>>n>>m;
    cin>>s;

    for(int i=1;i<n;i++){
        if(s[i] < s[i-1])
            cnt[s[i]-'a'][s[i-1]-'a'] += 1;
        else
            cnt[s[i-1]-'a'][s[i]-'a'] += 1;
    }

    // for(int i=0;i<26;i++){
    //     for(int j=0;j<26;j++){
    //         cnt[i][j] /= 2;
    //     }
    // }

    dp[0] = 0;
    int cur = 0;
    for(int i=0;i<(1<<m);i++){
        cur = __builtin_popcountll(i);
        // cout<<cur;
        for(int j=0;j<m;j++){
            int add = 0;
            if( (i & (1<<j))){
                for(int k=0;k<m;k++){

                    if(j == k) continue;

                    if( (i & (1<<k)) )
                        add +=cnt[min(j,k)][max(j,k)];
                    else
                        add -=cnt[min(j,k)][max(j,k)];
                }
            }
            dp[i] = min(dp[i],dp[i^(1<<j)] + (cur+1)*add);
        }

    }
    // for(int i=0;i<(1<<m);i++){
    //     tr(i,dp[i]);
    // }
    cout<<dp[(1<<m)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}


/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int M = 20;
int n, m, sum[1 << M][M];
long long dp[1 << M];
string s;

int main() {
    cin >> n >> m >> s;
    for (int i = 1; i < n; i++)
        if (s[i] ^ s[i - 1]) {
            sum[1 << s[i - 1] - 'a'][s[i] - 'a']++;
            sum[1 << s[i] - 'a'][s[i - 1] - 'a']++;
        }
    memset(dp, 63, sizeof dp), dp[0] = 0;
    for (int i = 1; i < 1 << m; i++)
        for (int j = 0; j < m; j++)
            sum[i][j] = sum[i ^ i & -i][j] + sum[i & -i][j];
    for (int i = 1; i < 1 << m; i++)
        for (int j = 0; j < m; j++)
            if (i >> j & 1) {
                long long cost = dp[i ^ 1 << j];
                for (int p = 0; p < m; p++)
                    cost += i >> p & 1? sum[(1 << m) - 1 ^ i][p]: 0;
                dp[i] = min(dp[i], cost);
            }
    cout << dp[(1 << m) - 1];
}


#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

int cnt[26][26];
int dp[(1<<20)+10];

void solve()
{
    cin>>n>>m;
    cin>>s;

    for(int i=1;i<n;i++){
        if(s[i] < s[i-1])
            cnt[s[i]-'a'][s[i-1]-'a'] += 1;
        else
            cnt[s[i-1]-'a'][s[i]-'a'] += 1;
    }

    // for(int i=0;i<26;i++){
    //     for(int j=0;j<26;j++){
    //         cnt[i][j] /= 2;
    //     }
    // }

    vector<int> dp((1<<m),INF);

    dp[0] = 0;
    int cur = 0;
    for(int i=0;i<(1<<m);i++){
        cur = __builtin_popcountll(i);
        // cout<<cur;
        for(int j=0;j<m;j++){
            int add = 0;
            if( (i & (1<<j))){
                for(int k=0;k<m;k++){

                    if(j == k) continue;

                    if( (i & (1<<k)) )
                        add +=cnt[min(j,k)][max(j,k)];
                    else
                        add -=cnt[min(j,k)][max(j,k)];
                }
            }
            dp[i] = min(dp[i],dp[i^(1<<j)] + (cur+1)*add);
        }

    }
    // for(int i=0;i<(1<<m);i++){
    //     tr(i,dp[i]);
    // }
    cout<<dp[(1<<m)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}


#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

int cnt[26][26];
vector<int> dp((1<<20),INF);

void solve()
{
    cin>>n>>m;
    cin>>s;

    for(int i=1;i<n;i++){
        if(s[i] < s[i-1])
            cnt[s[i]-'a'][s[i-1]-'a'] += 1;
        else
            cnt[s[i-1]-'a'][s[i]-'a'] += 1;
    }

    // for(int i=0;i<26;i++){
    //     for(int j=0;j<26;j++){
    //         cnt[i][j] /= 2;
    //     }
    // }

    dp[0] = 0;
    int cur = 0;
    for(int i=0;i<(1<<m);i++){
        cur = __builtin_popcountll(i);
        // cout<<cur;
        for(int j=0;j<m;j++){
            int add = 0;
            if( (i & (1<<j))){
                for(int k=0;k<m;k++){

                    if(j == k) continue;

                    if( (i & (1<<k)) )
                        add +=cnt[min(j,k)][max(j,k)];
                    else
                        add -=cnt[min(j,k)][max(j,k)];
                }
            }
            dp[i] = min(dp[i],dp[i^(1<<j)] + (cur+1)*add);
        }

    }
    // for(int i=0;i<(1<<m);i++){
    //     tr(i,dp[i]);
    // }
    cout<<dp[(1<<m)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}


#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

int cnt[26][26];
int dp[(1<<20)+10];

void solve()
{
    cin>>n>>m;
    cin>>s;

    for(int i=1;i<n;i++){
        if(s[i] < s[i-1])
            cnt[s[i]-'a'][s[i-1]-'a'] += 1;
        else
            cnt[s[i-1]-'a'][s[i]-'a'] += 1;
    }

    // for(int i=0;i<26;i++){
    //     for(int j=0;j<26;j++){
    //         cnt[i][j] /= 2;
    //     }
    // }

    vector<int> dp((1<<m),INF);

    dp[0] = 0;

    for(int i=0;i<(1<<m);i++){
        int cur = 0;
        for(int j=0;j<m;j++){
            if( (i & (1<<j))){
                cur++;
            }
        }
        // cout<<cur;
        for(int j=0;j<m;j++){
            int add = 0;
            if( (i & (1<<j))){
                for(int k=0;k<m;k++){

                    if(j == k) continue;

                    if( (i & (1<<k)) )
                        add +=(cur+1)*cnt[min(j,k)][max(j,k)];
                    else
                        add -=(cur+1)*cnt[min(j,k)][max(j,k)];
                }
            }
            dp[i] = min(dp[i],dp[i^(1<<j)] + add);
        }

    }
    // for(int i=0;i<(1<<m);i++){
    //     tr(i,dp[i]);
    // }
    cout<<dp[(1<<m)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;
str t;
ll dp[1<<20], cnt[20][20], sm[20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    ll all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int mask=1; mask<all; mask++){
        ll mn = 1e18, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            ll tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<a; q++) for(int w=0; w<a; w++) sm[q] += cnt[q][w];
    for(int mask=1; mask<all; mask++){
        int mn = 1e9, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            int tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a,k; cin>>a>>k;
    str t; cin>>t;
    vec<vec<int>> c(k, vec<int>(k));
    for(int q=1; q<a; q++){
        c[t[q]-'a'][t[q-1]-'a']++;
        c[t[q-1]-'a'][t[q]-'a']++;
    }
    int s = 1<<k;
    vec<int> dp(s, 0);
    vec<vec<int>> add(s, vec<int>(k, -1)), rem(s, vec<int>(k, -1));
    vec<str> o(s, "");
    for(int q=1, uu=0; q<s; q++){
        int bt = __builtin_popcount(q);
        if(bt==1){
            o[q] = (char)('a'+uu); uu++;
            continue;
        }
        vec<int> n;
        for(int w=q, yy=0; w; w>>=1, yy++) if(w&1) n.pb(yy);
        str st;
        int mn = 1e8, ps = 0, og = 0;
        for(int g=0; g<n.size(); g++){
            int msk = q^(1<<n[g]), cost = dp[msk], cmn = 0, cps=0;
            str ss = o[msk];
            int pl = 0, pr = 0, ml = 0, mr = msk;
            for(int w=0; w<ss.size(); w++) cost+=(w+1)*c[n[g]][ss[w]-'a'], pr+=c[ss[w]-'a'][n[g]];
            cmn = cost;
            if(g==0) mn = cmn, st = o[msk];
            for(int p=1; p<=ss.size(); p++){
                pl += p==1 ? 0 : c[ss[p-2]-'a'][n[g]];
                pr -= c[ss[p-1]-'a'][n[g]];
                ml ^= p==1 ? 0 : 1<<(ss[p-2]-'a');
                mr ^= 1<<(ss[p-1]-'a');
                if(add[ml][ss[p-1]-'a']==-1) for(int w=p-2; w>=0; w--) add[ml][ss[p-1]-'a'] += c[ss[w]-'a'][ss[p-1]-'a'];
                if(rem[mr][ss[p-1]-'a']==-1) for (int w = p; w < ss.size(); w++) rem[mr][ss[p-1]-'a'] += c[ss[w] - 'a'][ss[p - 1] - 'a'];
                cost+=rem[mr][ss[p-1]-'a']+pl-pr-add[ml][ss[p-1]-'a'];
                if(cost < cmn) cmn = cost, cps = p;
            }
            if(cmn < mn) mn = cmn, ps = cps, st = o[msk], og = g;
        }
        dp[q] = mn;
        o[q] = st;
        o[q].insert(o[q].begin()+ps, (char)('a'+n[og]));
    }
    cout<<dp[s-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<k; q++) for(int w=0; w<k; w++) sm[q] += cnt[q][w];
    for(int mask=1; mask<all; mask++){
        int mn = 1e9, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            int tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;
str t;
ll dp[1<<20], cnt[20][20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    ll all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int mask=1; mask<all; mask++){
        ll mn = 1e18, ps = __builtin_popcount(mask)+999;
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            ll tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;
str t;
ll dp[1<<20], cnt[20][20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    ll all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int mask=1; mask<all; mask++){
        ll mn = 1e18, ps = __builtin_popcount(mask);
        for(int q=0; q<a; q++){
            if(!(mask&(1<<q))) continue;
            ll tyt = dp[mask-(1<<q)];
            for(int w=0; w<a; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a,k; cin>>a>>k;
    str t; cin>>t;
    vec<vec<int>> c(k, vec<int>(k));
    for(int q=1; q<a; q++){
        c[t[q]-'a'][t[q-1]-'a']++;
        c[t[q-1]-'a'][t[q]-'a']++;
    }
    int s = 1<<k;
    vec<int> dp(s, 0);
    vec<str> o(s, "");
    for(int q=1, uu=0; q<s; q++){
        int bt = __builtin_popcount(q);
        if(bt==1){
            o[q] = (char)('a'+uu); uu++;
            continue;
        }
        vec<int> n;
        for(int w=q, yy=0; w; w>>=1, yy++) if(w&1) n.pb(yy);
        str os = "";
        int mn = 1e8, ps = 0;
        for(int g=0; g<1; g++){
            int msk = q^(1<<n[g]), b = dp[msk], tt=0;
            o[q] = o[msk];
            str ss = o[msk];
            for(int w=0; w<ss.size(); w++) tt+=(w+1)*c[n[g]][ss[w]-'a'];
            mn = b+tt;
            for(int p=1; p<=ss.size(); p++){
                for(int w=p-2; w>=0; w--) tt += c[ss[w]-'a'][n[g]];
                for(int w = p; w<ss.size(); w++) tt -= c[ss[w]-'a'][n[g]];
                for(int w=p-2; w>=0; w--) b -= c[ss[p-1]-'a'][ss[w]-'a'];
                for(int w = p; w<ss.size(); w++) b += c[ss[p-1]-'a'][ss[w]-'a'];
                if(b+tt < mn) mn = b+tt, ps = p;
            }
            dp[q] = mn;
            o[q].insert(o[q].begin()+ps, (char)('a'+n[g]));
        }
    }
    cout<<dp[s-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20], E[20][1<<20];

int main() {
    fast;
    memset(E, 0, sizeof(E));
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<k; q++) for(int w=0; w<k; w++) sm[q] += cnt[q][w];
    for(int q=0; q<k; q++){
        for(int mask=1; mask<all; mask++){
            E[q][mask] = cnt[q][__builtin_ctz(mask)] + E[q][mask&(mask-1)];
        }
    }
    for(int mask=1; mask<all; mask++){
        int mn = 1e9, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            int umsk = E[q][mask]*ps - (sm[q]-E[q][mask])*ps;
            int tyt = dp[mask-(1<<q)] + umsk;
            /*for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }*/
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<a; q++) for(int w=0; w<a; w++) sm[q] += cnt[q][w];
    for(int mask=1; mask<all; mask++){
        int mn = 1e18, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            int tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn =min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;
str t;
ll dp[1<<20], cnt[20][20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    ll all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int mask=1; mask<all; mask++){
        ll mn = 1e18, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            ll tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a,k; cin>>a>>k;
    str t; cin>>t;
    vec<vec<int>> c(k, vec<int>(k));
    for(int q=1; q<a; q++){
        c[t[q]-'a'][t[q-1]-'a']++;
        c[t[q-1]-'a'][t[q]-'a']++;
    }
    int s = 1<<k;
    vec<int> dp(s, 0);
    vec<str> o(s, "");
    for(int q=1, uu=0; q<s; q++){
        int bt = __builtin_popcount(q);
        if(bt==1){
            o[q] = (char)('a'+uu); uu++;
            continue;
        }
        vec<int> n;
        for(int w=q, yy=0; w; w>>=1, yy++) if(w&1) n.pb(yy);
        int mn, ps = 0;
        for(int g=0; g<1; g++){
            int msk = q^(1<<n[g]), b = dp[msk], tt=0;
            o[q] = o[msk];
            str ss = o[msk];
            for(int w=0; w<ss.size(); w++) tt+=(w+1)*c[n[g]][ss[w]-'a'];
            mn = b+tt;
            for(int p=1; p<=ss.size(); p++){
                for(int w=p-2; w>=0; w--) tt += c[ss[w]-'a'][n[g]];
                for(int w = p; w<ss.size(); w++) tt -= c[ss[w]-'a'][n[g]];
                for(int w=p-2; w>=0; w--) b -= c[ss[p-1]-'a'][ss[w]-'a'];
                for(int w = p; w<ss.size(); w++) b += c[ss[p-1]-'a'][ss[w]-'a'];
                if(b+tt < mn) mn = b+tt, ps = p;
            }
            dp[q] = mn;
            o[q].insert(o[q].begin()+ps, (char)('a'+n[g]));
        }
    }
    cout<<dp[s-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20], E[20][1<<20];

int main() {
    fast;
    memset(E, 0, sizeof(E));
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<k; q++) for(int w=0; w<k; w++) sm[q] += cnt[q][w];
    for(int q=0; q<k; q++){
        for(int mask=1; mask<all; mask++){
            E[q][mask] = cnt[q][__builtin_ctz(mask)] + E[q][mask&(mask-1)];
        }
    }
    for(int mask=1; mask<all; mask++){
        int mn = 1e9, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(mask&(1<<q)) mn = min(mn, dp[mask-(1<<q)] + (E[q][mask]*2 - sm[q])*ps);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k;
str t;
int dp[1<<20], cnt[20][20], sm[20];

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    cin>>a>>k>>t;
    int all = 1<<k;
    for(int q=1; q<a; q++){
        int x = t[q]-'a', y = t[q-1]-'a';
        if(x==y) continue;
        cnt[x][y]++;
        cnt[y][x]++;
    }
    for(int q=0; q<a; q++) for(int w=0; w<a; w++) sm[q] += cnt[q][w];
    for(int mask=1; mask<all; mask++){
        int mn = 1e9, ps = __builtin_popcount(mask);
        for(int q=0; q<k; q++){
            if(!(mask&(1<<q))) continue;
            int tyt = dp[mask-(1<<q)];
            for(int w=0; w<k; w++){
                if(q==w) continue;
                if(mask&(1<<w)) tyt += cnt[q][w]*ps;
                else tyt -= cnt[q][w]*ps;
            }
            mn = min(mn, tyt);
        }
        dp[mask] = mn;
    }
    cout<<dp[all-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a,k; cin>>a>>k;
    str t; cin>>t;
    vec<vec<int>> c(k, vec<int>(k));
    for(int q=1; q<a; q++){
        c[t[q]-'a'][t[q-1]-'a']++;
        c[t[q-1]-'a'][t[q]-'a']++;
    }
    int s = 1<<k;
    vec<int> dp(s, 0);
    vec<str> o(s, "");
    for(int q=1, uu=0; q<s; q++){
        int bt = __builtin_popcount(q);
        if(bt==1){
            o[q] = (char)('a'+uu); uu++;
            continue;
        }
        vec<int> n;
        for(int w=q, yy=0; w; w>>=1, yy++) if(w&1) n.pb(yy);
        str st;
        int mn = 1e8, ps = 0, og = 0;
        for(int g=0; g<n.size(); g++){
            int msk = q^(1<<n[g]), b = dp[msk], tt=0, cmn = 0, cps=0;
            str ss = o[msk];
            for(int w=0; w<ss.size(); w++) tt+=(w+1)*c[n[g]][ss[w]-'a'];
            cmn = b+tt;
            if(g==0) mn = cmn, st = o[msk];
            for(int p=1; p<=ss.size(); p++){
                for(int w=p-2; w>=0; w--) tt += c[ss[w]-'a'][n[g]];
                for(int w = p; w<ss.size(); w++) tt -= c[ss[w]-'a'][n[g]];
                for(int w=p-2; w>=0; w--) b -= c[ss[p-1]-'a'][ss[w]-'a'];
                for(int w = p; w<ss.size(); w++) b += c[ss[p-1]-'a'][ss[w]-'a'];
                if(b+tt < cmn) cmn = b+tt, cps = p;
            }
            if(cmn < mn) mn = cmn, ps = cps, st = o[msk], og = g;
        }
        dp[q] = mn;
        o[q] = st;
        o[q].insert(o[q].begin()+ps, (char)('a'+n[og]));
    }
    cout<<dp[s-1];
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a,k; cin>>a>>k;
    str t; cin>>t;
    vec<vec<int>> c(k, vec<int>(k));
    for(int q=1; q<a; q++){
        c[t[q]-'a'][t[q-1]-'a']++;
        c[t[q-1]-'a'][t[q]-'a']++;
    }
    int s = 1<<k;
    vec<int> dp(s, 0);
    vec<vec<int>> add(s, vec<int>(k, -1)), rem(s, vec<int>(k, -1));
    vec<str> o(s, "");
    for(int q=1, uu=0; q<s; q++){
        int bt = __builtin_popcount(q);
        if(bt==1){
            o[q] = (char)('a'+uu); uu++;
            continue;
        }
        vec<int> n;
        for(int w=q, yy=0; w; w>>=1, yy++) if(w&1) n.pb(yy);
        str st;
        int mn = 1e8, ps = 0, og = 0;
        for(int g=0; g<n.size(); g++){
            int msk = q^(1<<n[g]), cost = dp[msk], cmn = 0, cps=0;
            str ss = o[msk];
            int pl = 0, pr = 0, ml = 0, mr = msk;
            for(int w=0; w<ss.size(); w++) cost+=(w+1)*c[n[g]][ss[w]-'a'], pr+=c[ss[w]-'a'][n[g]];
            cmn = cost;
            if(g==0) mn = cmn, st = o[msk];
            for(int p=1; p<=ss.size(); p++){
                pl += p==1 ? 0 : c[ss[p-2]-'a'][n[g]];
                pr -= c[ss[p-1]-'a'][n[g]];
                int lf = 0, rg = 0;
                ml ^= p==1 ? 0 : 1<<(ss[p-2]-'a');
                if(add[ml][ss[p-1]-'a']==-1){
                    for(int w=p-2; w>=0; w--) lf += c[ss[w]-'a'][ss[p-1]-'a'];
                    add[ml][ss[p-1]-'a'] = lf;
                }
                lf = add[ml][ss[p-1]-'a'];
                mr ^= 1<<(ss[p-1]-'a');
                if(rem[mr][ss[p-1]-'a']==-1) {
                    for (int w = p; w < ss.size(); w++) rg += c[ss[w] - 'a'][ss[p - 1] - 'a'];
                    rem[mr][ss[p-1]-'a'] = rg;
                }
                rg = rem[mr][ss[p-1]-'a'];
                cost-=lf;
                cost+=rg;
                cost+=pl;
                cost-=pr;
                if(cost < cmn) cmn = cost, cps = p;
            }
            if(cmn < mn) mn = cmn, ps = cps, st = o[msk], og = g;
        }
        dp[q] = mn;
        o[q] = st;
        o[q].insert(o[q].begin()+ps, (char)('a'+n[og]));
    }
    cout<<dp[s-1];
}


#include <bits/stdc++.h>
using namespace std;
const int ms = 21;
int dp[1<<ms], n, m;
int adj[ms][ms];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] != s[i]) {
			adj[s[i]-'a'][s[i-1]-'a']++;
			adj[s[i-1]-'a'][s[i]-'a']++;
		}
	}
	memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;
	for(int mask = 0; mask < (1<<m); mask++) {
		for(int i = 0; i < m; i++) {
			if(mask&(1<<i)) {
				int add = 0, on = __builtin_popcount(mask);
				for(int j = 0; j < m; j++) {
					int go = adj[i][j];
					if(mask&(1<<j)) add += on*go;
					else add -= on*go;
				}
				dp[mask] = min(dp[mask], add+dp[mask^(1<<i)]);
			}
		}
	}
	cout << dp[(1<<m)-1] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int ms = 21, inf = 1e9;
bool vis[ms][1<<ms];
int dp[ms][1<<ms], n, m;
int adj[ms][ms];

int solve(int pos, int mask) {
	int &ans = dp[pos][mask];
	if(vis[pos][mask])
		return ans;
	vis[pos][mask] = true;
	int add = 0, on = 0, best = inf;
	for(int i = 0; i < m; i++) {
		if((mask&(1<<i)) == 0)
			best = min(best, solve(i, mask|(1<<i)));
		else
			on++;
	}
	if(best == inf)
		best = 0;
	for(int i = 0; i < m; i++) {
		if(mask&(1<<i)) add += on*adj[pos][i];
		else add -= on*adj[pos][i];
	}
 	return ans = best+add;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] != s[i]) {
			adj[s[i]-'a'][s[i-1]-'a']++;
			adj[s[i-1]-'a'][s[i]-'a']++;
		}
	}
	int ans = inf;
	for(int i = 0; i < m; i++)
		ans = min(ans, solve(i, 1<<i));
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int ms = 21, inf = 1e9;
bool vis[ms][1<<ms];
int dp[ms][1<<ms], n, m;
vector<int> adj[ms];

int solve(int pos, int mask) {
	int &ans = dp[pos][mask];
	if(vis[pos][mask])
		return ans;
	vis[pos][mask] = true;
	int add = 0, on = 0, best = inf;
	for(int i = 0; i < m; i++) {
		if((mask&(1<<i)) == 0)
			best = min(best, solve(i, mask|(1<<i)));
		else
			on++;
	}
	if(best == inf)
		best = 0;
	for(auto v : adj[pos]) {
		if(mask&(1<<v)) add += on;
		else add -= on;
	}
 	return ans = best+add;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] != s[i]) {
			adj[s[i]-'a'].push_back(s[i-1]-'a');
			adj[s[i-1]-'a'].push_back(s[i]-'a');
		}
	}
	int ans = inf;
	for(int i = 0; i < m; i++)
		ans = min(ans, solve(i, 1<<i));
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int ms = 21, inf = 1e9;
bool vis[ms][1<<ms];
int dp[ms][1<<ms], n, m;
vector<int> adj[ms];

int solve(int pos, int mask) {
	int &ans = dp[pos][mask];
	if(vis[pos][mask])
		return ans;
	vis[pos][mask] = true;
	int add = 0, on =  __builtin_popcount(mask)-1;
	for(auto v : adj[pos]) {
		if(mask&(1<<v)) add += on;
		else add -= on;
	}
	ans = inf;
	for(int i = 0; i < m; i++) {
		if((mask&(1<<i)) == 0)
			ans = min(ans, add+solve(i, mask|(1<<i)));
	}
	if(ans == inf)
		ans = add;
 	return ans;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] != s[i]) {
			adj[s[i]-'a'].push_back(s[i-1]-'a');
			adj[s[i-1]-'a'].push_back(s[i]-'a');
		}
	}
	int ans = inf;
	for(int i = 0; i < m; i++)
		ans = min(ans, solve(i, 1<<i));
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int ms = 21, inf = 1e9;
bool vis[ms][1<<ms];
int dp[1<<ms], n, m;
int adj[ms][ms];

/*int solve(int pos, int mask) {
	int &ans = dp[pos][mask];
	if(vis[pos][mask])
		return ans;
	vis[pos][mask] = true;
	int add = 0, on = 0, best = inf;
	for(int i = 0; i < m; i++) {
		if((mask&(1<<i)) == 0)
			best = min(best, solve(i, mask|(1<<i)));
		else
			on++;
	}
	if(best == inf)
		best = 0;
	for(int i = 0; i < m; i++) {
		if(mask&(1<<i)) add += on*adj[pos][i];
		else add -= on*adj[pos][i];
	}
 	return ans = best+add;
}*/

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i-1] != s[i]) {
			adj[s[i]-'a'][s[i-1]-'a']++;
			adj[s[i-1]-'a'][s[i]-'a']++;
		}
	}
	memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;
	for(int mask = 0; mask < (1<<m); mask++) {
		for(int i = 0; i < m; i++) {
			if(mask&(1<<i)) {
				int add = 0, on = __builtin_popcount(mask);
				for(int j = 0; j < m; j++) {
					int go = adj[i][j];
					if(mask&(1<<j)) add += on*go;
					else add -= on*go;
				}
				dp[mask] = min(dp[mask], add+dp[mask^(1<<i)]);
			}
		}
	}
	cout << dp[(1<<m)-1] << endl;
	return 0;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

#define lint long long
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define lint long long

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
int modpow(int base, int exp, int modulo) {
  base %= modulo;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 1e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;
const int LN = 20 ;

// int after[20], before[20] ;
string s ;
int n, m ;
int cnt[21][21] ;
int dp[LN][N] ;

int solve(int pos, int mask)
{
    if(pos < 0) return 0;
    if(dp[pos][mask] != -1) return dp[pos][mask] ;

    int ans = 1e9 ;
    for(int i = 0; i < m; i++)
    {
        if(!(mask & (1 << i)))
        {
            int marks = 0 ;
            int aft = 0, bef = 0 ;
            for(int j = 0; j < m; j++)
            {
                if(mask & (1 << j))
                    aft += cnt[i][j] ;
                else
                    bef += cnt[i][j] ;
            }
            marks -= (aft * pos); marks += (bef * pos);
            ans = min(ans, marks + solve(pos - 1, mask | (1 << i) ) ) ;
        }
    }
    return dp[pos][mask] = ans ;
}

int main()
{
    cin >> n >> m >> s ; memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i < n; i++)
    {
        int cur = s[i] - 'a', prev = s[i - 1] - 'a' ;
        cnt[cur][prev]++, cnt[prev][cur]++ ;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(m-1, 0);
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

#define lint long long
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define lint long long

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
int modpow(int base, int exp, int modulo) {
  base %= modulo;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 2e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;
const int LN = 20 ;

// int after[20], before[20] ;
string s ;
int n, m ;
int cnt[21][21] ;
lint dp[LN][N] ;

lint solve(int pos, int mask)
{
    if(pos < 0) return 0;
    if(dp[pos][mask] != -1) return dp[pos][mask] ;

    lint ans = 1e18 ;
    for(int i = 0; i < m; i++)
    {
        if(!(mask & (1 << i)))
        {
            lint marks = 0 ;
            lint aft = 0, bef = 0 ;
            for(int j = 0; j < m; j++)
            {
                if(j == i) continue ;
                if(mask & (1 << j))
                    aft += cnt[i][j] ;
                else
                    bef += cnt[i][j] ;
            }
            marks += (bef * (pos + 1)); marks -= (aft * (pos + 1));
            ans = min(ans, marks + solve(pos - 1, mask | (1 << i) ) ) ;
        }
    }
    return dp[pos][mask] = ans ;
}

int main()
{
    cin >> n >> m >> s ; memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i < n; i++)
    {
        int cur = s[i] - 'a', prev = s[i - 1] - 'a' ;
        cnt[cur][prev]++, cnt[prev][cur]++ ;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(m-1, 0);
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

#define lint long long
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define lint long long

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b);

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
int modpow(int base, int exp, int modulo) {
  base %= modulo;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 2e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;
const int LN = 20 ;

// int after[20], before[20] ;
string s ;
int n, m ;
int cnt[21][21] ;
int dp[LN][N] ;

int solve(int pos, int mask)
{
    if(pos < 0) return 0;
    if(dp[pos][mask] != -1) return dp[pos][mask] ;

    int ans = 1e9 ;
    for(int i = 0; i < m; i++)
    {
        if(!(mask & (1 << i)))
        {
            int marks = 0 ;
            int aft = 0, bef = 0 ;
            for(int j = 0; j < m; j++)
            {
                if(mask & (1 << j))
                    aft += cnt[i][j] ;
                else
                    bef += cnt[i][j] ;
            }
            marks -= (aft * pos); marks += (bef * pos);
            ans = min(ans, marks + solve(pos - 1, mask | (1 << i) ) ) ;
        }
    }
    return dp[pos][mask] = ans ;
}

int main()
{
    cin >> n >> m >> s ; memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i < n; i++)
    {
        int cur = s[i] - 'a', prev = s[i - 1] - 'a' ;
        cnt[cur][prev]++, cnt[prev][cur]++ ;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(m-1, 0);
}