Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
int main(){
  int n,k,count=0,max,i;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
    if(s[i]==s[i+1])
      count++;
  max=count+2*k;
  if(n>max)
    printf("%d\n",max);
  else
    printf("%d\n",n-1);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -84(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -80(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-80(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-80(%rbp), %eax
	addl	$1, %eax
	movq	-64(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	jne	.L6
	addl	$1, -84(%rbp)
.L6:
	addl	$1, -80(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L7
	movl	-88(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L8
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rsi
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L37:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L37
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L38
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %edx
	testl	%edx, %edx
	jle	.L29
	leal	-1(%rdx), %eax
	cmpl	$14, %eax
	jbe	.L30
	movl	%edx, %ecx
	pxor	%xmm1, %xmm1
	pxor	%xmm5, %xmm5
	movq	%rsp, %rax
	shrl	$4, %ecx
	movdqa	.LC2(%rip), %xmm6
	pxor	%xmm4, %xmm4
	salq	$4, %rcx
	addq	%rsp, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	1(%rax), %xmm7
	movdqu	(%rax), %xmm0
	movdqa	%xmm5, %xmm3
	addq	$16, %rax
	pcmpeqb	%xmm7, %xmm0
	pand	%xmm6, %xmm0
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rcx
	jne	.L7
	movdqa	%xmm1, %xmm0
	movl	%edx, %ecx
	psrldq	$8, %xmm0
	andl	$-16, %ecx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	testb	$15, %dl
	je	.L5
.L6:
	leal	1(%rcx), %esi
	movslq	%ecx, %r8
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, (%rbx,%r8)
	sete	%r8b
	movzbl	%r8b, %r8d
	addl	%r8d, %eax
	cmpl	%edx, %esi
	jge	.L5
	leal	2(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%dil, %r8b
	sete	%dil
	movzbl	%dil, %edi
	addl	%edi, %eax
	cmpl	%edx, %esi
	jge	.L5
	leal	3(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L12
	addl	$1, %eax
.L12:
	cmpl	%esi, %edx
	jle	.L5
	leal	4(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L13
	addl	$1, %eax
.L13:
	cmpl	%esi, %edx
	jle	.L5
	leal	5(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L14
	addl	$1, %eax
.L14:
	cmpl	%esi, %edx
	jle	.L5
	leal	6(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L15
	addl	$1, %eax
.L15:
	cmpl	%esi, %edx
	jle	.L5
	leal	7(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L16
	addl	$1, %eax
.L16:
	cmpl	%esi, %edx
	jle	.L5
	leal	8(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L17
	addl	$1, %eax
.L17:
	cmpl	%esi, %edx
	jle	.L5
	leal	9(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L18
	addl	$1, %eax
.L18:
	cmpl	%esi, %edx
	jle	.L5
	leal	10(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	je	.L39
.L19:
	cmpl	%esi, %edx
	jle	.L5
	leal	11(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	je	.L40
.L20:
	cmpl	%esi, %edx
	jle	.L5
	leal	12(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	je	.L41
.L21:
	cmpl	%esi, %edx
	jle	.L5
	leal	13(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	je	.L42
.L22:
	cmpl	%esi, %edx
	jle	.L5
	leal	14(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L23
	addl	$1, %eax
.L23:
	cmpl	%esi, %edx
	jle	.L5
	addl	$15, %ecx
	movslq	%ecx, %rcx
	cmpb	%r8b, (%rbx,%rcx)
	jne	.L5
	addl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	movl	-28(%rbp), %ecx
	leal	(%rax,%rcx,2), %r8d
	cmpl	%edx, %r8d
	jge	.L26
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L27:
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L43
	movq	-8(%rbp), %rbx
	xorl	%eax, %eax
	leave
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L26:
	.cfi_restore_state
	subl	$1, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L27
.L38:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L39:
	addl	$1, %eax
	jmp	.L19
.L40:
	addl	$1, %eax
	jmp	.L20
.L41:
	addl	$1, %eax
	jmp	.L21
.L42:
	addl	$1, %eax
	jmp	.L22
.L29:
	xorl	%eax, %eax
	jmp	.L5
.L30:
	xorl	%ecx, %ecx
	xorl	%eax, %eax
	jmp	.L6
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rsi
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L37:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L37
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L38
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %edx
	testl	%edx, %edx
	jle	.L29
	leal	-1(%rdx), %eax
	cmpl	$14, %eax
	jbe	.L30
	movl	%edx, %ecx
	pxor	%xmm1, %xmm1
	pxor	%xmm5, %xmm5
	movq	%rsp, %rax
	shrl	$4, %ecx
	movdqa	.LC2(%rip), %xmm6
	pxor	%xmm4, %xmm4
	salq	$4, %rcx
	addq	%rsp, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	1(%rax), %xmm7
	movdqu	(%rax), %xmm0
	movdqa	%xmm5, %xmm3
	addq	$16, %rax
	pcmpeqb	%xmm7, %xmm0
	pand	%xmm6, %xmm0
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rcx
	jne	.L7
	movdqa	%xmm1, %xmm0
	movl	%edx, %ecx
	psrldq	$8, %xmm0
	andl	$-16, %ecx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	testb	$15, %dl
	je	.L5
.L6:
	leal	1(%rcx), %esi
	movslq	%ecx, %r8
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, (%rbx,%r8)
	sete	%r8b
	movzbl	%r8b, %r8d
	addl	%r8d, %eax
	cmpl	%edx, %esi
	jge	.L5
	leal	2(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%dil, %r8b
	sete	%dil
	movzbl	%dil, %edi
	addl	%edi, %eax
	cmpl	%edx, %esi
	jge	.L5
	leal	3(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L12
	addl	$1, %eax
.L12:
	cmpl	%esi, %edx
	jle	.L5
	leal	4(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L13
	addl	$1, %eax
.L13:
	cmpl	%esi, %edx
	jle	.L5
	leal	5(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L14
	addl	$1, %eax
.L14:
	cmpl	%esi, %edx
	jle	.L5
	leal	6(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L15
	addl	$1, %eax
.L15:
	cmpl	%esi, %edx
	jle	.L5
	leal	7(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L16
	addl	$1, %eax
.L16:
	cmpl	%esi, %edx
	jle	.L5
	leal	8(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L17
	addl	$1, %eax
.L17:
	cmpl	%esi, %edx
	jle	.L5
	leal	9(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	jne	.L18
	addl	$1, %eax
.L18:
	cmpl	%esi, %edx
	jle	.L5
	leal	10(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	je	.L39
.L19:
	cmpl	%esi, %edx
	jle	.L5
	leal	11(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	je	.L40
.L20:
	cmpl	%esi, %edx
	jle	.L5
	leal	12(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	je	.L41
.L21:
	cmpl	%esi, %edx
	jle	.L5
	leal	13(%rcx), %esi
	movslq	%esi, %rdi
	movzbl	(%rbx,%rdi), %edi
	cmpb	%dil, %r8b
	je	.L42
.L22:
	cmpl	%esi, %edx
	jle	.L5
	leal	14(%rcx), %esi
	movslq	%esi, %r8
	movzbl	(%rbx,%r8), %r8d
	cmpb	%r8b, %dil
	jne	.L23
	addl	$1, %eax
.L23:
	cmpl	%esi, %edx
	jle	.L5
	addl	$15, %ecx
	movslq	%ecx, %rcx
	cmpb	%r8b, (%rbx,%rcx)
	jne	.L5
	addl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	movl	-28(%rbp), %ecx
	leal	(%rax,%rcx,2), %r8d
	cmpl	%edx, %r8d
	jge	.L26
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L27:
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L43
	movq	-8(%rbp), %rbx
	xorl	%eax, %eax
	leave
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L26:
	.cfi_restore_state
	subl	$1, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L27
.L38:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L39:
	addl	$1, %eax
	jmp	.L19
.L40:
	addl	$1, %eax
	jmp	.L20
.L41:
	addl	$1, %eax
	jmp	.L21
.L42:
	addl	$1, %eax
	jmp	.L22
.L29:
	xorl	%eax, %eax
	jmp	.L5
.L30:
	xorl	%ecx, %ecx
	xorl	%eax, %eax
	jmp	.L6
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
int main(){
  int n,k,count=0,max,i;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
    if(s[i]==s[i+1])
      count++;
  max=count+2*k;
  if(n>max)
    printf("%d\n",max);
  else
    printf("%d\n",n-1);
  return 0;
}

6 2
LRLRRL
 9 3
RRRLRLRLL
 9 0
RRRLRLRLL
 6 0
LRRLRL
 9 1
RRRRLLRLL
 9 1
RLRRLLLRR
 6 1
RRLLRL
 10 2
LLLLLRRRRR
 13 4
LRRLRLRRLRLLR
 13 8
LRRLRLRRLRLLR

5
 8
 3
 1
 7
 6
 4
 9
 11
 12

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
int main(){
  int n,k,count=0,max,i;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
    if(s[i]==s[i+1])
      count++;
  max=count+2*k;
  if(n>max)
    printf("%d\n",max);
  else
    printf("%d\n",n-1);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -84(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -80(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-80(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-80(%rbp), %eax
	addl	$1, %eax
	movq	-64(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	jne	.L6
	addl	$1, -84(%rbp)
.L6:
	addl	$1, -80(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L7
	movl	-88(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L8
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -84(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -80(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-80(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-80(%rbp), %eax
	addl	$1, %eax
	movq	-64(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	jne	.L6
	addl	$1, -84(%rbp)
.L6:
	addl	$1, -80(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L7
	movl	-88(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L8
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
