#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 scanf(char *, int *, char *);
int main(void) {
  int n, i, ret = 0, err;
  char kupon[500000];
  err = scanf("%d %s", &n, kupon);
  i = 0;
  while (i < n - 1) {
    if (kupon[i] == kupon[i + 1]) {
      ++ret;
      ++i;
    }
    ++i;
  }
  printf("%d\n", ret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x7a140(%rbp),%rdx
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b0 <main+0x90>
movslq -0xc(%rbp),%rax
movsbl -0x7a140(%rbp,%rax,1),%eax
ff
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x7a140(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    11a2 <main+0x82>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <main+0x3a>
mov    -0x10(%rbp),%esi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7a140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x7a138,%rsp
lea    0xed2(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <scanf@plt>
mov    0xc(%rsp),%r8d
xor    %esi,%esi
cmp    $0x2,%r8d
jl     1187 <main+0x67>
add    $0xffffffff,%r8d
xor    %ecx,%ecx
xor    %esi,%esi
jmp    116c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %al,%dl
add    %edx,%esi
add    $0x1,%ecx
cmp    %r8d,%ecx
jge    1187 <main+0x67>
movslq %ecx,%rdi
movzbl 0x10(%rsp,%rdi,1),%eax
xor    %edx,%edx
cmp    0x11(%rsp,%rdi,1),%al
sete   %al
jne    1160 <main+0x40>
add    $0x1,%rdi
mov    %edi,%ecx
jmp    1160 <main+0x40>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7a138,%rsp
ret

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

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