program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,k
    integer(int32):: i,cnt=0
    character(:),allocatable::  s

    read*, n,k
    allocate(character(n):: s)
    read*, s

    do i=2,n
        if (s(i-1:i-1) /= s(i:i)) cnt=cnt+1
    end do

    do i=1,k
        cnt=cnt-2
    end do

    print'(i0)', n-1 - max(cnt,0)

end program main