      program answer
        implicit none
        character(len=1),allocatable,dimension(:) :: S
        integer :: N,K
        integer :: i,cn
        integer :: ans
        cn=0
        read(*,*) N,K
        allocate(S(N))
        read(*,'(100000A1)') (S(i),i=1,N)
        do i=1,N-1
          if( S(i) .ne. S(i+1)) then
            cn=cn+1
          end if
        end do
        ans = N - cn - 1 + 2*K
        if(ans .gt. N-1) ans = N-1
        write(*,'(I0)') ans
      end program answer
