function MinSteps(A, B, N) {
let dp = new Array(N + 1).fill(0);
for (let i = 1; i <= N; i++) {
if (A[i - 1] == B[i - 1]) {
dp[i] = dp[i - 1];
}
else {
dp[i] = dp[i - 1] + 1;
}
if (i >= 2 && A[i - 2] == B[i - 1]
&& A[i - 1] == B[i - 2]) {
dp[i] = Math.min(dp[i], dp[i - 2] + 1);
}
}
return dp[N];
}
function solve(N, s){
let str1=""
if(s[0]===1){
a=0;
b=1;
}
else{
a=1;
b=0;
}
for(let i=1; i<=N; i++){
if(i%2==0){
str1+=a;
}
else{
str1+=b;
}
}
return(MinSteps(s,str1,N))
}
console.log(solve(5,"11010"))