#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define INP "solve"
#define OUT "solve"

const long long INF_LL = 4e18;
const int INF = 1e9 + 100;
const int MOD = 1e9 + 7;
const long double EPS = 1e-10;
const int BLOCK = 550;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());

void open_file() {
    #ifdef THEMIS
        freopen(INP ".inp","r",stdin);
        freopen(OUT ".out","w",stdout);
    #endif // THEMIS
}
const int maxN = 1e2 + 100;

void sol() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n + 1, INF);
    vector<int> mn(26, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        int c = s[i - 1] - 'a';
        for (int nc = 0; nc < 26; nc++) {
            if (c == nc) continue;
            dp[i] = min(dp[i], mn[nc] + 1);
        }
        mn[c] = min(mn[c], dp[i - 1]);
    }
    if (dp[n] == INF) cout << -1 << '\n';
    else cout << dp[n] << '\n';
}

void solve() {
    clock_t begin = clock();
    int T;
    //cin >> T;
    T = 1;
    int TestCase = 0;
    while (T--) {
        TestCase += 1;
        //cout << "Case #" << TestCase << ": ";
        //cout << "Test " << TestCase << ": ";
        sol();
        //if (T) cout << '\n';
    }
    clock_t end = clock();
    cerr << "Time: " << fixed << setprecision(10) << (double)(end - begin) / (double)CLOCKS_PER_SEC << '\n';
}

int main(int argc,char *argv[]) {
    ///srand(Time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    open_file();
    solve();
}

#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define pii pair <int , int>
#define mp make_pair
#define fs first
#define sc second
using namespace std;
typedef long long LL;

template <typename T>
void read(T &x) {
	T f=1;x=0;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=(x<<3)+(x<<1)+(s^'0');s=getchar();}
	x *= f;
}

template <typename T>
void write(T x , char s='\n') {
	if(!x) {putchar('0');putchar(s);return;}
	if(x<0) {putchar('-');x=-x;}
	T t = 0 , tmp[25] = {};
	while(x) tmp[t ++] = x % 10 , x /= 10;
	while(t -- > 0) putchar(tmp[t] + '0');
	putchar(s);
}

const int MAXN = 1e5 + 5;

int n , f[MAXN] , val[30];
char s[MAXN];

int main() {
	read(n);
	scanf("%s" , s + 1);
	memset(val , 127 , sizeof val);
	val[s[n] - 'a'] = 0;
	for (int i = n - 1; i >= 1; --i) {
		f[i] = 1e9;
		for (int j = 0; j < 26; ++j) if(val[j] < (int)(1e9) && s[i] - 'a' != j) f[i] = min(f[i] , val[j] + 1);
		if(f[i] < (int)1e9) val[s[i - 1] - 'a'] = min(val[s[i - 1] - 'a'] , f[i]);
	}
	if(f[1] < (int)1e9) write(f[1]);
	else puts("-1");
	return 0;
}