#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int n;string in;
    cin>>n>>in;
    vector<vector<int> > table(2,vector<int>(n+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(in[i-1]==in[n-j]) table[i%2][j]=table[(i-1)%2][j-1]+1;
            else table[i%2][j]=max(table[(i-1)%2][j],table[i%2][j-1]);
        }
    }
    cout<<n-table[n%2][n]<<endl;
}