Option Strict On
Module Module1

    Sub Main()
        Dim l() As String = Split(Console.ReadLine())
        Dim N As Integer = Convert.ToInt32(l(0))
        Dim K As Integer = Convert.ToInt32(l(1))
        Dim s As String = Console.ReadLine()
        Dim renzokucounter As Integer = 1
        Dim hairetuyou As Integer = 0
        Dim mojirenzoku(N - 1) As Integer
        For i As Integer = 0 To N - 1
            If Mid(s, i + 1, 1) = Mid(s, i + 2, 1) Then
                renzokucounter += 1
            Else
                mojirenzoku(hairetuyou) = renzokucounter
                hairetuyou += 1
                renzokucounter = 1
            End If

        Next
        ' For Each t In mojirenzoku
        'Console.WriteLine(t)
        'Next
        Dim sum As Integer = 0
        Dim max As Integer = 0
        Dim waku As Integer = 2 + 2 * (K - 1)
        If waku > hairetuyou Then
            waku = hairetuyou - 1
        End If
        'Console.WriteLine(hairetuyou)
        'Console.WriteLine(waku)
        For i As Integer = 0 To hairetuyou - 1
            sum = 0
            For j As Integer = 0 To waku
                sum += mojirenzoku(i + j)
            Next
            'Console.WriteLine(sum & " \")
            If max < sum Then
                max = sum
            End If
        Next
        'Console.WriteLine(waku)
        Console.WriteLine(max)
        Console.ReadLine()

    End Sub

End Module