#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	long N,i,br1=0,br2=0,br=0; char A[100];
	cin>>N;
	for(i=0;i<N;i++){
		cin>>A[i];
	};
	for(i=0;i<N-1;i++){
			if(A[i]>A[i+1])br1++;
	}
	for(i=0;i<N-1;i++){
			if(A[i]==A[i+1])br2++;
	}
	if(br2==0 && br1!=0)br=br1;
	else if(br2!=0 && br1==0)br=br2;
	else br=br2+br2*br1;
	cout<<br;
	return 0;
}