#include <iostream>
using namespace std;
int
f[2][5001], l, maxi; //为了优化空间,,使用了滚动数组
string
str, strr;
void
__read__()
{
cin >> l >> str;
}
void
__reverse__()
{
for( int i = 1; i <= l; i++ )
strr += str[l - i];
}
void
__lcs__()
{
int
cur = 1, old = 1;
for( int i = 1; i <= l; i++ )
{
cur = i % 2;
old = ( i - 1 ) % 2;
for( int j = 1; j <= l; j++ )
if( str[i - 1] == strr[j - 1] )
{
f[cur][j] = f[old][j - 1] + 1;
if( maxi < f[cur][j] )
maxi = f[cur][j];
}
else
{
if( f[old][j] > f[cur][j - 1] )
f[cur][j] = f[old][j];
else
f[cur][j] = f[cur][j - 1];
}
}
}
void
__outp__()
{
cout << l - maxi << endl;
}
int
main()
{
__read__();
__reverse__();
__lcs__();
__outp__();
return 0;
}