<Problem>
http://ntucoder.net/Problem/Details/4446
Uses Crt;
Var n,m,i,d1,d2:longint; st:ansistring;
Begin
readln(n,m);
readln(st);st:=st+st[1];
for i:=1 to length(st)-1 do
begin
if (st[i]='0') and (st[i+1]='0') then inc(d1);
if (st[i]='1') and (st[i+1]='1') then inc(d2);
end;
writeln(abs(d1-d2));
readln;
End.