#include<stdio.h>

signed main(){
int i,nn[100],x,n,k;
scanf("%d %d",&x,&n);
scanf("%ls",nn);
k=x;
for(i=1;nn[i]!='\0';i++){
x-=i;
if(nn[i-1]!=k){
printf("%d\n",x);
  break;
} 
x+=i;  
x+=i;
if(nn[i-1]!=k){
printf("%d\n",x);
  break;
}  
 x-=i; 

}




return 0;
}