/*
Template:
By Jugal :)
*/
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vii;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define len length()
#define rep(i,n) for(int i=0;i<n;i++)
#define ref(i,a,n) for(int i=a;i<=n;i++)
#define reb(i,n,a) for(int i=n;i>=a;i--)
#define all(a) a.begin(),a.end()
#define gi(n) scanf("%d",&n)
#define pi(n) printf("%d",n)
#define ps printf(" ")
#define pn printf("\n")
char str[100000];
int main()
{
int n,ans=0;
scanf("%d",&n);
scanf("%s",str);
int dp[2][100000];
int *prev=dp[0],*cur=dp[1];
ref(i,1,n) {
ref(j,1,n) {
if(str[i-1]==str[n-j]) cur[j]=1+prev[j-1],ans=max(cur[j],ans);
else cur[j]=0;
}
int *temp;
temp=prev;
prev=cur;
cur=temp;
}
pi(n-ans);pn;
return 0;
}
LyoKICAgIFRlbXBsYXRlOgogICAgQnkgSnVnYWwgOikKKi8KCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDx1dGlsaXR5PiAKI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGxpbWl0cz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiB2ZWN0b3IgPGludD4gdmk7CnR5cGVkZWYgdmVjdG9yIDx2aT4gdmlpOwp0eXBlZGVmIHBhaXI8aW50LGludD4gcGlpOwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBmZiBmaXJzdAojZGVmaW5lIHNzIHNlY29uZAojZGVmaW5lIHN6IHNpemUoKQojZGVmaW5lIGxlbiBsZW5ndGgoKQojZGVmaW5lIHJlcChpLG4pIGZvcihpbnQgaT0wO2k8bjtpKyspCiNkZWZpbmUgcmVmKGksYSxuKSBmb3IoaW50IGk9YTtpPD1uO2krKykKI2RlZmluZSByZWIoaSxuLGEpIGZvcihpbnQgaT1uO2k+PWE7aS0tKQojZGVmaW5lIGFsbChhKSBhLmJlZ2luKCksYS5lbmQoKQojZGVmaW5lIGdpKG4pIHNjYW5mKCIlZCIsJm4pCiNkZWZpbmUgcGkobikgcHJpbnRmKCIlZCIsbikKI2RlZmluZSBwcyBwcmludGYoIiAiKQojZGVmaW5lIHBuIHByaW50ZigiXG4iKQoKY2hhciBzdHJbMTAwMDAwXTsKCmludCBtYWluKCkKewogICAgICAgIGludCBuLGFucz0wOwogICAgICAgIHNjYW5mKCIlZCIsJm4pOwogICAgICAgIHNjYW5mKCIlcyIsc3RyKTsKICAgICAgICBpbnQgZHBbMl1bMTAwMDAwXTsKICAgICAgICBpbnQgKnByZXY9ZHBbMF0sKmN1cj1kcFsxXTsKICAgICAgICByZWYoaSwxLG4pIHsKICAgICAgICAgICAgICAgIHJlZihqLDEsbikgewogICAgICAgICAgICAgICAgICAgICAgICBpZihzdHJbaS0xXT09c3RyW24tal0pIGN1cltqXT0xK3ByZXZbai0xXSxhbnM9bWF4KGN1cltqXSxhbnMpOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGN1cltqXT0wOwogICAgICAgICAgICAgICAgfQoJCWludCAqdGVtcDsKICAgICAgICAgICAgICAgIHRlbXA9cHJldjsKICAgICAgICAgICAgICAgIHByZXY9Y3VyOwogICAgICAgICAgICAgICAgY3VyPXRlbXA7CQogICAgICAgIH0KICAgICAgICBwaShuLWFucyk7cG47CiAgICAgICAgcmV0dXJuIDA7Cn0K