#include <stdio.h>
int main(){
long long n;
scanf("%lld",&n);
char x[n];
scanf("%s",x);
printf("0 = %c, n-1 = %c\n",x[0],x[n-1]);
long long index = -1,count = 0;
if(x[0] == x[n-1]) {printf("%lld",n-1);
return 0;}
else{
printf("Hi");
for(int i = 1; i < n-1; i++){
if(x[0] == x[i] ) index = i;
}
if(index == -1) {count = 0;
index = 0;}
else count += index;
long index2 = -1;
for(int i = n-2; i > index; i--){
if(x[n-1] == x[i]) index2 = i;
}
if(index2 != -1) count+= (n-index2-1);
printf("%lld",count);}
}
Copy