#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int j, n, count = 0;
  scanf("%d", &n);
  char c[n];
  scanf("%s", c);
  for (int i = 0; i < n - 1; i++) {
    if (c[i] == c[i + 1]) {
      for (j = i; c[i] == c[j + 1]; j++)
        count++;
      i = j;
    }
  }
  printf("%d", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x30(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120c <main+0xec>
mov    -0x30(%rbp),%rcx
movslq -0x24(%rbp),%rax
movsbl (%rcx,%rax,1),%eax
mov    -0x24(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11f9 <main+0xd9>
mov    -0x24(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x30(%rbp),%rcx
movslq -0x24(%rbp),%rax
movsbl (%rcx,%rax,1),%eax
mov    -0x8(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11f3 <main+0xd3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bb <main+0x9b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11fe <main+0xde>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <main+0x63>
mov    -0x10(%rbp),%esi
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xecf(%rip),%rdi
xor    %ebx,%ebx
lea    -0x1c(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%r15
mov    -0x1c(%rbp),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xea7(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
cmp    $0x2,%eax
jl     11b3 <main+0x93>
add    $0xffffffff,%eax
lea    0x1(%r14),%r8
xor    %edx,%edx
xor    %ebx,%ebx
jmp    118a <main+0x6a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rsi
mov    %esi,%edx
cmp    %eax,%edx
jge    11b3 <main+0x93>
movslq %edx,%rsi
mov    (%r14,%rsi,1),%cl
cmp    0x1(%r14,%rsi,1),%cl
jne    1180 <main+0x60>
add    %r8,%rsi
add    $0xffffffff,%ebx
xchg   %ax,%ax
add    $0x1,%edx
lea    0x1(%rsi),%rdi
add    $0x1,%ebx
cmp    (%rsi),%cl
mov    %rdi,%rsi
je     11a0 <main+0x80>
jmp    1186 <main+0x66>
lea    0xe46(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8, i64 %10
store i64 %10, i64* %6
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %7
br label %14
14: ; preds = %56, %0
%15 = load i32, i32* %7
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %59
19: ; preds = %14
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %12, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %12, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %24, %30
br i1 %31, label %32, label %55
32: ; preds = %19
%33 = load i32, i32* %7
store i32 %33, i32* %2
br label %34
34: ; preds = %50, %32
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %12, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %12, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %39, %45
br i1 %46, label %47, label %53
47: ; preds = %34
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %50
50: ; preds = %47
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %34
53: ; preds = %34
%54 = load i32, i32* %2
store i32 %54, i32* %7
br label %55
55: ; preds = %53, %19
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %14
59: ; preds = %14
%60 = load i32, i32* %4
%61 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = load i8*, i8** %5
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i8, i64 %5
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = load i32, i32* %1
%10 = add nsw i32 %9, -1
%11 = icmp sgt i32 %9, 1
br i1 %11, label %15, label %12
12: ; preds = %37, %0
%13 = phi i32 [ 0, %0 ], [ %39, %37 ]
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
15: ; preds = %0, %37
%16 = phi i32 [ %38, %37 ], [ 0, %0 ]
%17 = phi i32 [ %39, %37 ], [ 0, %0 ]
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %7, i64 %18
%20 = load i8, i8* %19
%21 = add nsw i32 %16, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %7, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %20, %24
br i1 %25, label %26, label %37
26: ; preds = %15, %26
%27 = phi i64 [ %29, %26 ], [ %18, %15 ]
%28 = phi i32 [ %33, %26 ], [ %17, %15 ]
%29 = add i64 %27, 1
%30 = getelementptr inbounds i8, i8* %7, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %20, %31
%33 = add nsw i32 %28, 1
br i1 %32, label %26, label %34
34: ; preds = %26
%35 = trunc i64 %27 to i32
%36 = add nsw i32 %35, 1
br label %37
37: ; preds = %34, %15
%38 = phi i32 [ %36, %34 ], [ %21, %15 ]
%39 = phi i32 [ %28, %34 ], [ %17, %15 ]
%40 = icmp slt i32 %38, %10
br i1 %40, label %15, label %12
}