 /*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/

#include <bits/stdc++.h>
using namespace std;

#define     ff              first
#define     ss              second
#define     pb(x)           push_back(x)
#define     mp              make_pair
#define     sz(x)           x.size()
#define     mem(x ,y)       memset(x , y , sizeof x )
#define     all(a )         a.begin() , a.end()
#define     endl            "\n"
#define     pii             pair<int,int>
#define     rep(i ,n )      for(int i = 0 ; i < n ; i++ )
#define     repi(i ,n )     for(int i = 1 ; i <= n ; i++ )
#define     forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define     ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define     repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define     dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;

typedef long long ll  ;
typedef unsigned long long  ull ;
typedef vector<int> vi  ;

const int  inf = 1e9+7  ;
const int  mod = 1e9+7;
const ll  INF = 1e17+7  ;

int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }

template < typename T > T mul(T x, T y   ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y  ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T modPow(T x, T k ,T mod ) { if(k == 0 ) return 1; if(k&1  ) { return ( (x%mod)*modPow(x,k-1, mod )%mod )%mod ; } else { T ret = modPow(x,k/2 , mod ) ; ret %= mod ; return (ret*ret )%mod; } }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}

template < typename T >
T  modInv( T x , T m = 1e9+7) {
    return modPow(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}

// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ "; rep(i,n )cerr<<a[i]<<' ' ; cerr<< " ]" <<  endl;
}

template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ "; rep(i , sz( v)  )  os << v[i] << ' ' ; return os << " ]" ;
}

//int dx[] = {0 , 0 ,+1, -1 } ;
//int dy[] = {-1, +1,0 , 0 };

const int M = (int )2e6+5;
const int mx  = 1000+23  ;

////  code from here ...

int  n   , dp[102][102 ]  ;
int td , tr ,ti , ts , prev[102 ][27] ,a[M +2 ];
string s1  ,s2  ;
int  func(int  i,int j  )  {
   // dbg( i ,j);
    if( i<1 and j<1) return 0 ;
    if(i<1 ) {
        return ti*j ;
    }
    if( j<1 ){
        return td*i  ;

    }

    int &ans = dp[i][j] ;
    if( ans!=-1) return ans ;

    ans = inf ;
    if(s1[i] == s2[j] ) {
        ans = func(i-1 ,j-1) ;

    } else {

        //insert
        ans = min(ans , func( i ,j-1)+ ti  ) ;

        // delete
        ans = min(ans, func(i-1,j ) + td ) ;
        // replace
        ans = min(ans, func(i-1,j-1) + tr )  ;
        //swap

        if(s2[j-1]==s1[i] and prev[i][s2[j]-'a']>0 and j>1 and i>1 ) {
            int w =  i- prev[i][s2[j]-'a'] -1  ;
            w = w*td ;
          //  dbg(j , w,ts ,prev[i][s2[j]-'a']) ;
            ans = min(ans  , w+ ts+ func(prev[i][s2[j]-'a'] - 1, j-2 )) ;

        }

    }

    return ans ;
}
void process() {
    repi(i , sz(s1 )-1) {
        rep(j, 26) {

            prev[i][j ] = a[j] ;

        }

        a[s1[i] -'a' ] =i ;

    }
    //dbg(prev[sz(s1)-1 ][0] ) ;

}
void solve() {
    cerr<< "program running ... " <<  endl ;
    int q , x ;
    cin >> ti >> td >> tr  >> ts ;
    cin >> s1 >> s2 ;
    mem(dp , -1) ;
    s1 =  " " + s1 ;
    s2 =  " " + s2  ;
    process() ;

    cout <<  func(sz(s1)-1 , sz( s2)-1 )  << endl  ;

}

int main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
        //    freopen("out.txt", "w", stdout);
    #endif
    ios ::sync_with_stdio(false);  cin.tie(0); cout.tie(0) ;

    int t=1 , c= 0 ;

    //  cin >> t;

    while(t-- ) {
        solve() ;

    }
    return 0 ;

}


 /*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/

#include <bits/stdc++.h>
using namespace std;

#define     ff              first
#define     ss              second
#define     pb(x)           push_back(x)
#define     mp              make_pair
#define     sz(x)           x.size()
#define     mem(x ,y)       memset(x , y , sizeof x )
#define     all(a )         a.begin() , a.end()
#define     endl            "\n"
#define     pii             pair<int,int>
#define     rep(i ,n )      for(int i = 0 ; i < n ; i++ )
#define     repi(i ,n )     for(int i = 1 ; i <= n ; i++ )
#define     forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define     ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define     repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define     dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;

typedef long long ll  ;
typedef unsigned long long  ull ;
typedef vector<int> vi  ;

const int  inf = 1e9+7  ;
const int  mod = 1e9+7;
const ll  INF = 1e17+7  ;

int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }

template < typename T > T mul(T x, T y   ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y  ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T modPow(T x, T k ,T mod ) { if(k == 0 ) return 1; if(k&1  ) { return ( (x%mod)*modPow(x,k-1, mod )%mod )%mod ; } else { T ret = modPow(x,k/2 , mod ) ; ret %= mod ; return (ret*ret )%mod; } }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}

template < typename T >
T  modInv( T x , T m = 1e9+7) {
    return modPow(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}

// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ "; rep(i,n )cerr<<a[i]<<' ' ; cerr<< " ]" <<  endl;
}

template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ "; rep(i , sz( v)  )  os << v[i] << ' ' ; return os << " ]" ;
}

//int dx[] = {0 , 0 ,+1, -1 } ;
//int dy[] = {-1, +1,0 , 0 };

const int M = (int )2e6+5;
const int mx  = 1000+23  ;

////  code from here ...

int  n   , dp[102][102 ]  ;
int td , tr ,ti , ts , pre[102 ][27] ,a[M +2 ];
string s1  ,s2  ;
int  func(int  i,int j  )  {
   // dbg( i ,j);
    if( i<1 and j<1) return 0 ;
    if(i<1 ) {
        return ti*j ;
    }
    if( j<1 ){
        return td*i  ;

    }

    int &ans = dp[i][j] ;
    if( ans!=-1) return ans ;

    ans = inf ;
    if(s1[i] == s2[j] ) {
        ans = func(i-1 ,j-1) ;

    } else {

        //insert
        ans = min(ans , func( i ,j-1)+ ti  ) ;

        // delete
        ans = min(ans, func(i-1,j ) + td ) ;
        // replace
        ans = min(ans, func(i-1,j-1) + tr )  ;
        //swap

        if(s2[j-1]==s1[i] and pre[i][s2[j]-'a']>0 and j>1 and i>1 ) {
            int w =  i- pre[i][s2[j]-'a'] -1  ;
            w = w*td ;
          //  dbg(j , w,ts ,prev[i][s2[j]-'a']) ;
            ans = min(ans  , w+ ts+ func(pre[i][s2[j]-'a'] - 1, j-2 )) ;

        }

    }

    return ans ;
}
void process() {
    repi(i , sz(s1 )-1) {
        rep(j, 26) {

            pre[i][j ] = a[j] ;

        }

        a[s1[i] -'a' ] =i ;

    }
    //dbg(prev[sz(s1)-1 ][0] ) ;

}
void solve() {
    cerr<< "program running ... " <<  endl ;
    int q , x ;
    cin >> ti >> td >> tr  >> ts ;
    cin >> s1 >> s2 ;
    mem(dp , -1) ;
    s1 =  " " + s1 ;
    s2 =  " " + s2  ;
    process() ;

    cout <<  func(sz(s1)-1 , sz( s2)-1 )  << endl  ;

}

int main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
        //    freopen("out.txt", "w", stdout);
    #endif
    ios ::sync_with_stdio(false);  cin.tie(0); cout.tie(0) ;

    int t=1 , c= 0 ;

    //  cin >> t;

    while(t-- ) {
        solve() ;

    }
    return 0 ;

}


//idea : http://www.voidcn.com/article/p-ffzklags-ur.html
/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/

#include <bits/stdc++.h>
using namespace std;

#define     ff              first
#define     ss              second
#define     pb(x)           push_back(x)
#define     mp              make_pair
#define     sz(x)           x.size()
#define     mem(x ,y)       memset(x , y , sizeof x )
#define     all(a )         a.begin() , a.end()
#define     endl            "\n"
#define     pii             pair<int,int>
#define     rep(i ,n )      for(int i = 0 ; i < n ; i++ )
#define     repi(i ,n )     for(int i = 1 ; i <= n ; i++ )
#define     forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define     ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define     repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define     dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;

typedef long long ll  ;
typedef unsigned long long  ull ;
typedef vector<int> vi  ;

const int  inf = 1e9+7  ;
const int  mod = 1e9+7;
const ll  INF = 1e17+7  ;

int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }

template < typename T > T mul(T x, T y   ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y  ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T modPow(T x, T k ,T mod ) { if(k == 0 ) return 1; if(k&1  ) { return ( (x%mod)*modPow(x,k-1, mod )%mod )%mod ; } else { T ret = modPow(x,k/2 , mod ) ; ret %= mod ; return (ret*ret )%mod; } }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}

template < typename T >
T  modInv( T x , T m = 1e9+7) {
    return modPow(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}

// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ "; rep(i,n )cerr<<a[i]<<' ' ; cerr<< " ]" <<  endl;
}

template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ "; rep(i , sz( v)  )  os << v[i] << ' ' ; return os << " ]" ;
}

//int dx[] = {0 , 0 ,+1, -1 } ;
//int dy[] = {-1, +1,0 , 0 };

const int M = (int )2e6+5;
const int mx  = 1000+23  ;

////  code from here ...

int  n  , td , tr ,ti , ts  ;
int  dp[mx+2 ][mx+2  ]  , pre_b[mx+2  ][26] ,pre[ mx+2  ][27] ,a[ mx +2 ];
string s1  ,s2  ;
int  func(int  i,int j  )  {
   // dbg( i ,j);
    if( i<1 and j<1) return 0 ;
    if(i<1 ) {
        return ti*j ;
    }
    if( j<1 ){
        return td*i  ;

    }

    int &ans = dp[i][j] ;
    if( ans!=-1) return ans ;

    ans = inf ;
    if(s1[i] == s2[j] ) {
        ans = func(i-1 ,j-1) ;

    } else {

        //insert
        ans = min(ans , func( i ,j-1)+ ti  ) ;

        // delete
        ans = min(ans, func(i-1,j ) + td ) ;
        // replace
        ans = min(ans, func(i-1,j-1) + tr )  ;
        //swap

        if( pre[i ][s2[ j]-'a' ] >0  and pre_b[ j ][s1[i] -'a']>0  and j>1 and i>1 ) {
            int w1 , w2 , na = pre[i][s2[ j ]-'a' ] , nb  =   pre_b[j ][s1[i ]-'a' ] ;
            w1 = i-na -1 ; w1*=  td ;
            w2 = j-nb-1 ; w2 *=  ti ;

          //  dbg(i,j ,na,nb, w1,w2 ) ;
            ans = min(ans, w1+w2 + ts+ func( na-1,nb-1) ) ;

        }

    }

    return ans ;
}
void process() {
    repi(i , sz(s1 )-1) {
        rep(j, 26) {

            pre[i][j ] = a[j] ;

        }

        a[s1[i] -'a' ] =i ;

    }
    mem(a, 0 ) ;
    repi( i, sz(s2)-1) {

        rep(j, 26) {
            pre_b[i][j] = a[j] ;

        }
        a[s2[i]-'a' ] = i ;
    }
    //dbg(prev[sz(s1)-1 ][0] ) ;

}
void solve() {
    cerr<< "program running ... " <<  endl ;
    int q , x ;
    cin >> ti >> td >> tr  >> ts ;
    cin >> s1 >> s2 ;
    mem(dp , -1) ;
    s1 =  " " + s1 ;
    s2 =  " " + s2  ;
    process() ;

    cout <<  func(sz(s1)-1 , sz( s2)-1 )  << endl  ;

}

int main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
        //    freopen("out.txt", "w", stdout);
    #endif
    ios ::sync_with_stdio(false);  cin.tie(0); cout.tie(0) ;

    int t=1 , c= 0 ;

    //  cin >> t;

    while(t-- ) {
        solve() ;

    }
    return 0 ;

}


//idea : http://www.voidcn.com/article/p-ffzklags-ur.html
/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/

#include <bits/stdc++.h>
using namespace std;

#define     ff              first
#define     ss              second
#define     pb(x)           push_back(x)
#define     mp              make_pair
#define     sz(x)           x.size()
#define     mem(x ,y)       memset(x , y , sizeof x )
#define     all(a )         a.begin() , a.end()
#define     endl            "\n"
#define     pii             pair<int,int>
#define     rep(i ,n )      for(int i = 0 ; i < n ; i++ )
#define     repi(i ,n )     for(int i = 1 ; i <= n ; i++ )
#define     forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define     ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define     repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define     dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;

typedef long long ll  ;
typedef unsigned long long  ull ;
typedef vector<int> vi  ;

const int  inf = 1e9+7  ;
const int  mod = 1e9+7;
const ll  INF = 1e17+7  ;

int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }

template < typename T > T mul(T x, T y   ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y  ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T modPow(T x, T k ,T mod ) { if(k == 0 ) return 1; if(k&1  ) { return ( (x%mod)*modPow(x,k-1, mod )%mod )%mod ; } else { T ret = modPow(x,k/2 , mod ) ; ret %= mod ; return (ret*ret )%mod; } }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}

template < typename T >
T  modInv( T x , T m = 1e9+7) {
    return modPow(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}

// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ "; rep(i,n )cerr<<a[i]<<' ' ; cerr<< " ]" <<  endl;
}

template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ "; rep(i , sz( v)  )  os << v[i] << ' ' ; return os << " ]" ;
}

//int dx[] = {0 , 0 ,+1, -1 } ;
//int dy[] = {-1, +1,0 , 0 };

const int M = (int )2e6+5;
const int mx  = 4000+23  ;

////  code from here ...

int  n  , td , tr ,ti , ts  ;
int  dp[mx+2 ][mx+2  ]  , pre_b[mx+2  ][26] ,pre[ mx+2  ][27] ,a[ mx +2 ];
string s1  ,s2  ;
int  func(int  i,int j  )  {
   // dbg( i ,j);
    if( i<1 and j<1) return 0 ;
    if(i<1 ) {
        return ti*j ;
    }
    if( j<1 ){
        return td*i  ;

    }

    int &ans = dp[i][j] ;
    if( ans!=-1) return ans ;

    ans = inf ;
    if(s1[i] == s2[j] ) {
        ans = func(i-1 ,j-1) ;

    } else {

        //insert
        ans = min(ans , func( i ,j-1)+ ti  ) ;

        // delete
        ans = min(ans, func(i-1,j ) + td ) ;
        // replace
        ans = min(ans, func(i-1,j-1) + tr )  ;
        //swap

        if( pre[i ][s2[ j]-'a' ] >0  and pre_b[ j ][s1[i] -'a']>0  and j>1 and i>1 ) {
            int w1 , w2 , na = pre[i][s2[ j ]-'a' ] , nb  =   pre_b[j ][s1[i ]-'a' ] ;
            w1 = i-na -1 ; w1*=  td ;
            w2 = j-nb-1 ; w2 *=  ti ;

          //  dbg(i,j ,na,nb, w1,w2 ) ;
            ans = min(ans, w1+w2 + ts+ func( na-1,nb-1) ) ;

        }

    }

    return ans ;
}
void process() {
    repi(i , sz(s1 )-1) {
        rep(j, 26) {

            pre[i][j ] = a[j] ;

        }

        a[s1[i] -'a' ] =i ;

    }
    mem(a, 0 ) ;
    repi( i, sz(s2)-1) {

        rep(j, 26) {
            pre_b[i][j] = a[j] ;

        }
        a[s2[i]-'a' ] = i ;
    }
    //dbg(prev[sz(s1)-1 ][0] ) ;

}
void solve() {
    cerr<< "program running ... " <<  endl ;
    int q , x ;
    cin >> ti >> td >> tr  >> ts ;
    cin >> s1 >> s2 ;
    mem(dp , -1) ;
    s1 =  " " + s1 ;
    s2 =  " " + s2  ;
    process() ;

    cout <<  func(sz(s1)-1 , sz( s2)-1 )  << endl  ;

}

int main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
        //    freopen("out.txt", "w", stdout);
    #endif
    ios ::sync_with_stdio(false);  cin.tie(0); cout.tie(0) ;

    int t=1 , c= 0 ;

    //  cin >> t;

    while(t-- ) {
        solve() ;

    }
    return 0 ;

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n, k, j, jX, mx = 0;
	string s;
	cin >> n >> k >> s;
	for (char i = 'a'; i < 'z'; i++)
	{
		j = jX = 0;
		for (int u = 0; u < n; u++)
		{
			if (s[u] == i)
				j++;
			else
				j = 0;
			if (j == k)
			{
				jX++;
				j = 0;
			}
		}
		mx = max(mx, jX);
	}
	cout << mx;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n, k, j, jX, mx = 0;
	string s;
	cin >> n >> k >> s;
	for (char i = 'a'; i <= 'z'; i++)
	{
		j = jX = 0;
		for (int u = 0; u < n; u++)
		{
			if (s[u] == i)
				j++;
			else
				j = 0;
			if (j == k)
			{
				jX++;
				j = 0;
			}
		}
		mx = max(mx, jX);
	}
	cout << mx;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

bool ok(string s)
{
	for (int i = 0; i < (int)s.size() - 1; ++i)
		if (s[i] != s[i + 1])
			return false;
	return true;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	map<string, int> subs;
	for (int i = 0; i <= (int)s.size() - k; ++i)
	{
		string sub = s.substr(i, k);
		if (!ok(sub)) continue;
		if (subs.count(sub) == 0) subs.insert(make_pair(sub, 1));
		else subs.at(sub)++;
		i += k - 1;
	}
	int ans = 0;
	for (auto it = subs.begin(); it != subs.end(); ++it)
		ans = max(ans, it->second);
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
#ifdef _DEBUG
	freopen("zahuir.in", "r", stdin);
#endif

	int n, k; string s;
	cin >> n >> k >> s;

	map<string, int> res;
	int x = 0;

	for (int i = 0; i < k; ++i)
	{
		for (int j = i; j + k <= n; ++j)
		{
			string curs = s.substr(j, k);

			bool equalFlag = true;
			for (int a = 0; a < k - 1; ++a)
			{
				if (curs[a] != curs[a + 1])
				{
					equalFlag = false;
					break;
				}
			}

			if (equalFlag == false) continue;

			if (res.find(curs) == res.end())
			{
				res.insert(make_pair(curs, 1));
			}
			else
			{
				res.at(curs)++;
			}

			if (j == i) j += k - 1;
		}

		for (auto it = res.begin(); it != res.end(); ++it)
		{
			x = max(x, it->second);
		}

		res.clear();
	}

	cout << x << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
	int n, k; string s;
	cin >> n >> k >> s;

	map<string, int> res;
	int x = 0;

	for (int i = 0; i < k; ++i)
	{
		for (int j = i; j + k < n; j += k)
		{
			string curs = s.substr(j, k);

			bool equalFlag = true;
			for (int a = 0; a < k - 1; ++a)
			{
				if (curs[a] != curs[a + 1])
				{
					equalFlag = false;
					break;
				}
			}

			if (equalFlag == false) continue;

			if (res.find(curs) == res.end())
			{
				res.insert(make_pair(curs, 1));
			}
			else
			{
				res.at(curs)++;
			}
		}

		for (auto it = res.begin(); it != res.end(); ++it)
		{
			x = max(x, it->second);
		}

		res.clear();
	}

	cout << x << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

bool ok(string s)
{
	for (int i = 0; i < (int)s.size() - 1; ++i)
		if (s[i] != s[i + 1])
			return false;
	return true;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	map<string, int> subs;
	for (int i = 0; i <= (int)s.size() - k; ++i)
	{
		string sub = s.substr(i, k);
		if (subs.count(sub) == 0) subs.insert(make_pair(sub, 1));
		else subs.at(sub)++;
		if (ok(sub)) i += k - 1;
	}
	int ans = 0;
	for (auto it = subs.begin(); it != subs.end(); ++it)
		if (ok(it->first)) ans = max(ans, it->second);
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
	int n, k; string s;
	cin >> n >> k >> s;

	map<string, int> res;
	int x = 0;

	for (int i = 0; i < k; ++i)
	{
		for (int j = i; j + k <= n; j += k)
		{
			string curs = s.substr(j, k);

			bool equalFlag = true;
			for (int a = 0; a < k - 1; ++a)
			{
				if (curs[a] != curs[a + 1])
				{
					equalFlag = false;
					break;
				}
			}

			if (equalFlag == false) continue;

			if (res.find(curs) == res.end())
			{
				res.insert(make_pair(curs, 1));
			}
			else
			{
				res.at(curs)++;
			}
		}

		for (auto it = res.begin(); it != res.end(); ++it)
		{
			x = max(x, it->second);
		}

		res.clear();
	}

	cout << x << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int A = 26;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> v(A);
	for (char c = 'a'; c <= 'z'; ++c)
	{
		int i = c - 'a', counter = 0;
		for (int j = 0; j < (int)s.size(); ++j)
		{
			if (s[j] == c) counter++;
			else counter = 0;
			if (counter == k)
			{
				v[i]++;
				counter = 0;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < A; ++i)
		ans = max(ans, v[i]);
	cout << ans << endl;
	return 0;
}


#include <fstream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
//#include <unordered_map>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <bitset>
#include <map>
#include <ctime>
#include <stdlib.h>
#define MAX 500000000000
#include <iostream>
#include <deque>
//#include "PEZai.h"
//#include <Tlhelp32.h>
using namespace std;
#define UNDEFINED 32432523
string s;
int n, m, apar[29], mex;
int main()
{
    cin >> n >> m >> s;
    for(int i = 0; i < s.size(); i++) {
        int cSize = 1;
        while(cSize < m && s[i] == s[i + 1]) {
            i++;
            cSize++;
        }
        if(cSize >= m)
            apar[s[i - 1] - 'a']++;
    }
    for(int i = 0; i < 27; i++)
        mex = max(mex, apar[i]);
    cout << mex;
}


#include <fstream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
//#include <unordered_map>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <bitset>
#include <map>
#include <ctime>
#include <stdlib.h>
#define MAX 500000000000
#include <iostream>
#include <deque>
//#include "PEZai.h"
//#include <Tlhelp32.h>
using namespace std;
#define UNDEFINED 32432523
string s;
int n, m, apar[29], mex;
int main()
{
    cin >> n >> m >> s;
    if(n == 1 && m == 1) { cout << 1; return 0;}
    for(int i = 0; i < s.size(); i++) {
        int cSize = 1;
        while(cSize < m && s[i] == s[i + 1]) {
            i++;
            cSize++;
        }
        if(cSize >= m)
            apar[s[i - 1] - 'a']++;
    }
    for(int i = 0; i < 27; i++)
        mex = max(mex, apar[i]);
    cout << mex;
}


#include <fstream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
//#include <unordered_map>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <bitset>
#include <map>
#include <ctime>
#include <stdlib.h>
#define MAX 500000000000
#include <iostream>
#include <deque>
//#include "PEZai.h"
//#include <Tlhelp32.h>
using namespace std;
#define UNDEFINED 32432523
string s;
int n, m, apar[29], mex;
int main()
{
    cin >> n >> m >> s;
    if(n == 1 && m == 1) { cout << 1; return 0;}
    for(int i = 0; i < s.size(); i++) {
        int cSize = 1;
        while(cSize < m && s[i] == s[i + 1]) {
            i++;
            cSize++;
        }
        if(cSize >= m)
            apar[s[i] - 'a']++;
    }
    for(int i = 0; i < 27; i++)
        mex = max(mex, apar[i]);
    cout << mex;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <ctime>
#include <set>
#include <vector>
#define pls 1000000007
using namespace std;
typedef long long ll;
string s;
int l,n,k;
int x,maxx=-1;
int main()
{

	cin>>n>>k>>s;
	l=s.size();
	for(int j=97;j<=97+26;++j){
		char c=j;
		int ans=0;
		for(int i=0;i<l;++i){
			int cnt=0;
			while(i<l&&s[i]==c&&cnt<k)
				cnt++,i++;
			if(cnt==k)
				ans++;
		}
		maxx=max(maxx,ans);
	}
	cout<<maxx<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <ctime>
#include <set>
#include <vector>
#define pls 1000000007
using namespace std;
typedef long long ll;
string s;
int l,n,k;
int x,maxx=-1;
int main()
{

	cin>>n>>k>>s;
	l=s.size();
	for(int j=97;j<=97+26;++j){
		char c=j;
		int ans=0;
		for(int i=0;i<l;++i){
			int cnt=0;
			while(i<l&&s[i]==c&&cnt<k)
				cnt++,i++;
			if(cnt)
				i--;
			if(cnt==k)
				ans++;

		}
		maxx=max(maxx,ans);
	}
	cout<<maxx<<endl;
	return 0;
}


#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

int main(void){
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int max = 0;
    for (int i = 0; i < 26; i++) {
        int cnt = 0, ren = 0;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == 'a' + i) {
                ren++;
                if (ren == k) {
                    cnt++;  ren = 0;
                }
            }
            else ren = 0;
        }
        if (cnt > max) max = cnt;
    }

    cout << max << endl;

}


#include <string>
#include <iostream>
#define max(a, b) ((a) > (b) ? (a) : (b))
using namespace std;

int n, k;
string s;
int cnt[128 + 10];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k >> s;
	int bg = 0;
	for (int i = 1; i < n; ++i) {
		if (i - bg >= k) {
			++cnt[s[bg]];
			bg = i;
		}
		if (s[bg] != s[i])
			bg = i;
	}
	if (n - bg >= k)
		++cnt[s[bg]];

	int ans = 0;
	for (int i = 0; i < 128; ++i)
		ans = max(ans, cnt[i]);
	cout << ans << '\n';
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;

int main(){
	int n,k ;
	cin>>n>>k;
	string s;
	cin>>s;
	int alpha[26];
	bool flag;
	for(int i=0;i<26;i++)
	{
		alpha[i]=0;
	}
	for(int i=0;i<s.length();i++)
	{
		flag=true;
		for(int j=0;j<k-1 ;j++)
		{
			if(j+i==s.length())
			{
				flag=false;
				break;
			}
			if(s[i+j]!=s[i+1+j])
			{
				flag=false;
				i=i+j;
				break;
			}
		}
		if(flag){
			alpha[s[i]-'a']++;
			i+=k-1;
		}
	}
	int ans=0;
	for(int i=0;i<26;i++)
	{
		if(alpha[i]>ans)
			ans=alpha[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;

int main(){
	int n,k ;
	cin>>n>>k;
	string s;
	cin>>s;
	int alpha[26];
	bool flag;
	for(int i=0;i<26;i++)
	{
		alpha[i]=0;
	}
	for(int i=0;i<s.length();i++)
	{
		flag=true;
		for(int j=0;j<k-1;j++)
		{
			if(s[i+j]!=s[i+1+j])
			{
				flag=false;
				break;
				i=i+i+j;
			}
		}
		if(flag){
			alpha[s[i]-'a']++;
			i+=k-1;
		}
	}
	int ans=0;
	for(int i=0;i<26;i++)
	{
		if(alpha[i]>ans)
			ans=alpha[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;

int main(){
	int n,k ;
	cin>>n>>k;
	string s;
	cin>>s;
	int alpha[26];
	bool flag;
	for(int i=0;i<26;i++)
	{
		alpha[i]=0;
	}
	for(int i=0;i<s.length();i++)
	{
		flag=true;
		for(int j=0;j<k-1;j++)
		{
			if(s[i+j]!=s[i+1+j])
			{
				flag=false;
				break;
			}
		}
		if(flag){
			alpha[s[i]-'a']++;
			i+=k-1;
		}
	}
	int ans=0;
	for(int i=0;i<26;i++)
	{
		if(alpha[i]>ans)
			ans=alpha[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;

int main(){
	int n,k ;
	cin>>n>>k;
	string s;
	cin>>s;
	int alpha[26];
	bool flag;
	for(int i=0;i<26;i++)
	{
		alpha[i]=0;
	}
	for(int i=0;i<s.length();i++)
	{
		flag=true;
		for(int j=0;j<k-1;j++)
		{
			if(s[i]!=s[i+1])
				flag=false;
		}
		if(flag){
			alpha[s[i]-'a']++;
			i+=k-1;
		}
	}
	int ans=0;
	for(int i=0;i<26;i++)
	{
		if(alpha[i]>ans)
			ans=alpha[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;

int main(){
	int n,k ;
	cin>>n>>k;
	string s;
	cin>>s;
	int alpha[26];
	bool flag;
	for(int i=0;i<26;i++)
	{
		alpha[i]=0;
	}
	for(int i=0;i<s.length();i++)
	{
		flag=true;
		for(int j=0;j<k-1;j++)
		{
			if(s[i+j]!=s[i+1+j])
				flag=false;
		}
		if(flag){
			alpha[s[i]-'a']++;
			i+=k-1;
		}
	}
	int ans=0;
	for(int i=0;i<26;i++)
	{
		if(alpha[i]>ans)
			ans=alpha[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#define ll long long

#define FOR(i,a,b)		for(ll i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

using namespace std;

int main(int argc, const char * argv[])
{
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<ll> val;
    REP(j, 'z' - 'a' + 1) {
        val.push_back(0);
    }

    int count = 0;
    int prev = 0;
    REP(j, n) {
        if (j == 0 ) {
            count = 1;
            prev = s[j];
        }
        else {
            if (s[j] == prev) {
                count++;
            }
            else {
                if (count >= k) {
                    val[prev - 'a'] = val[prev - 'a'] + count / k;
                }
                count = 1;
                prev = s[j];
            }
        }
    }

    if (count >= k) {
        val[prev - 'a'] = val[prev - 'a'] + count / k;
    }

    ll result = 0;
    REP(j, 'z' - 'a' + 1) {
        if (val[j] > result) {
            result = val[j];
        }
    }

    cout << result;

    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max=0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	for (i = 1; i < n; i++)
	{
		if (string[i] == string[i-1])
		{
			repeat++;
		}
		else
		{
			count[string[i - 1]] = count[string[i - 1]] + repeat / k;
			repeat = 1;
			if (count[string[i - 1]] > max)
			{
				max = count[string[i - 1]];
				maxcharcter = string[i - 1];
			}
		}
		if (i == n - 1)
		{
			if (string[i] == string[i - 1])
			{
				repeat++;
				count[string[i - 1]] = count[string[i - 1]] + repeat / k;
				if (count[string[i]] > max)
				{
					max = count[string[i]];
					maxcharcter = string[i];
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max = 0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	for (i = 1; i < n; i++)
	{
		if (string[i] == string[i-1])
		{
			repeat++;
		}
		else
		{
			count[string[i - 1]] = count[string[i - 1]] + repeat / k;//老板结账
			repeat = 1;
			if (count[string[i - 1]] > max)
			{
				max = count[string[i - 1]];
				maxcharcter = string[i - 1];
			}
		}
		if (i == n - 1)
		{
			if (string[i] == string[i - 1])
			{
				count[string[i]] = count[string[i]] + repeat / k;
				if (count[string[i]] > max)
				{
					max = count[string[i]];
					maxcharcter = string[i];
				}
			}
			if (k == 1)
			{
				count[string[i]]++;
				if (count[string[i]] > max)
				{
					max = count[string[i]];
					maxcharcter = string[i];
				}

			}
		}
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max = 0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	if (k == 1)
	{
		for (i = 0; i < n; i++)
		{
			count[string[i]]++;
			if (count[string[i]] > max)max = count[string[i]];
		}
	}
	else
	{
		for (i = 1; i < n; i++)
		{
			if (string[i] == string[i - 1])
			{
				repeat++;
			}
			else
			{
				count[string[i - 1]] = count[string[i - 1]] + repeat / k;
				repeat = 1;
				if (count[string[i - 1]] > max)
				{
					max = count[string[i - 1]];
					maxcharcter = string[i - 1];
				}
			}
			if (i == n - 1)
			{
				if (string[i] == string[i - 1])
				{
					repeat++;
					count[string[i - 1]] = count[string[i - 1]] + repeat / k;
					if (count[string[i]] > max)
					{
						max = count[string[i]];
						maxcharcter = string[i];
					}
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max = 0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	if (k == 1)
	{
		for (i = 0; i < n; i++)
		{
			count[string[i]]++;
			if (count[string[i]] > max)
				max = count[string[i]];
		}
	}
	else
	{
		for (i = 1; i < n; i++)
		{
			if (string[i] == string[i - 1])
			{
				repeat++;
			}
			else
			{
				count[string[i - 1]] = count[string[i - 1]] + repeat / k;
				repeat = 1;
				if (count[string[i - 1]] > max)
				{
					max = count[string[i - 1]];
					maxcharcter = string[i - 1];
				}
			}
			if (i == n - 1)
			{
				if (string[i] == string[i - 1])
				{
					count[string[i - 1]] = count[string[i - 1]] + repeat / k;
					if (count[string[i]] > max)
					{
						max = count[string[i]];
						maxcharcter = string[i];
					}
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max=0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	for (i = 1; i < n; i++)
	{
		if (string[i] == string[i-1])
		{
			repeat++;
		}
		else
		{
			count[string[i - 1]] = count[string[i - 1]] + repeat / k;
			repeat = 1;
			if (count[string[i - 1]] > max)
			{
				max = count[string[i - 1]];
				maxcharcter = string[i - 1];
			}
		}
		if (i == n - 1)
		{
			if (string[i] == string[i - 1])
			{
				count[string[i - 1]] = count[string[i - 1]] + repeat / k;
				if (count[string[i]] > max)
				{
					max = count[string[i]];
					maxcharcter = string[i];
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
	int n = 0, k = 0;
	char string[200050];
	int count[150] = { 0 };
	int i = 0, j = 0, repeat = 1;
	int max = 0;
	char maxcharcter;
	scanf("%d%d", &n, &k);
	scanf("%s", string,sizeof(string));
	for (i = 0; i < n; i++)
	{
		if (k == 1)
		{
			count[string[i]]++;
			if (count[string[i]] > max)max = count[string[i]];
		}
		else
		{
			if (i == 0)i++;
			if (string[i] == string[i - 1])
			{
				repeat++;
			}
			else
			{
				count[string[i - 1]] = count[string[i - 1]] + repeat / k;//老板结账
				repeat = 1;
				if (count[string[i - 1]] > max)
				{
					max = count[string[i - 1]];
					maxcharcter = string[i - 1];
				}
			}
			if (i == n - 1)
			{
				if (string[i] == string[i - 1])
				{
					repeat++;
					count[string[i]] = count[string[i]] + repeat / k;
					if (count[string[i]] > max)
					{
						max = count[string[i]];
						maxcharcter = string[i];
					}
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	/*vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}*/

	vector<char> types;
	//vector<int> levels;

	long level = 0;
	for (int i = 0; i < input.length();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			int cnt = 0;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					cnt++;
					if (cnt == k) {
						total++;
						j++;
						cnt = 0;
					}
					else
						j++;
				}
				else
					j++;
			}
			types.emplace_back(temp);
			//levels.emplace_back(total);
			if (total > level)
				level = total;
		}
	}

	/*long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}*/

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}

	vector<char> types;
	vector<int> levels;

	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					if (nums[j] >= k) {
						total++;
						j += k;
					}
					else
						j++;
				}
				else
					j++;
			}
			types.emplace_back(temp);
			levels.emplace_back(total);
		}
	}

	long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	/*vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}*/

	vector<char> types;
	//vector<int> levels;

	long level = 0;
	for (int i = 0; i < input.length();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			int cnt = 0;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					cnt++;
					if (cnt == k) {
						total++;
						j++;
						cnt = 0;
					}
					else
						j++;
				}
				else {
					j++;
					cnt = 0;
				}
			}
			types.emplace_back(temp);
			//levels.emplace_back(total);
			if (total > level)
				level = total;
		}
	}

	/*long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}*/

	cout << level;

	return 0;
}


#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}

	vector<char> types;
	vector<int> levels;

	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					if (nums[j] >= k) {
						total++;
						j += k;
					}
					else
						j+=nums[j];
				}
				else
					j+=nums[j];
			}
			types.emplace_back(temp);
			levels.emplace_back(total);
		}
	}

	long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}

	vector<char> types;
	vector<int> levels;

	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					if (nums[j] >= k) {
						total++;
						j += k;
					}
					else
						j+=nums[j];
				}
				else
					j+=nums[j];
			}
			types.emplace_back(temp);
			levels.emplace_back(total);
		}
	}

	long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	/*vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}*/

	vector<char> types;
	//vector<int> levels;

	long level = 0;
	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			int cnt = 0;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					cnt++;
					if (cnt == k) {
						total++;
						j++;
						cnt = 0;
					}
					else
						j++;
				}
				else
					j++;
			}
			types.emplace_back(temp);
			//levels.emplace_back(total);
			if (total > level)
				level = total;
		}
	}

	/*long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}*/

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}

	vector<char> types;
	vector<int> levels;

	long level;
	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					if (nums[j] >= k) {
						total++;
						j += k;
					}
					else
						j+=nums[j];
				}
				else
					j+=nums[j];
			}
			types.emplace_back(temp);
			//levels.emplace_back(total);
			if (total > level)
				level = total;
		}
	}

	/*long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}*/

	cout << level;

	return 0;
}


//#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <math.h>

using namespace std;

int n, k;

bool search(char chr, vector<char> types) {
	for (int i = 0; i < types.size(); i++) {
		if (types[i] == chr)
			return true;
	}
	return false;
}

int main() {

	string input;
	cin >> n >> k >> input;

	vector<int> nums;

	for (int i = 0; i < input.length(); i++) {
		int cnt = 0;
		for (int j = i; j < input.length();+j++) {
			if (input.at(i) == input.at(j))
				cnt++;
			else
				break;
		}
		nums.emplace_back(cnt);
	}

	vector<char> types;
	vector<int> levels;

	long level = 0;
	for (int i = 0; i < nums.size();i++) {
		long total = 0;
		char temp = input.at(i);
		if (!search(temp, types)) {
			int j = i;
			while (j < input.length()) {
				if (input.at(j) == temp) {
					if (nums[j] >= k) {
						total++;
						j += k;
					}
					else
						j+=nums[j];
				}
				else
					j+=nums[j];
			}
			types.emplace_back(temp);
			//levels.emplace_back(total);
			if (total > level)
				level = total;
		}
	}

	/*long level = 0;
	for (int i = 0; i < levels.size();i++) {
		if (levels[i] > level)
			level = levels[i];
	}*/

	cout << level;

	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
char a[200000];
int main()
{
	int n, k; int t=0;
	cin >> n >> k;
	getchar();
	while (1)
	{
		a[t] = getchar();
		if (a[t] == '\n') break;
		t++;
	}
	int MAX = 0;
	for (char m = 'a'; m <= 'z'; m++)
	{
		int sum = 0;
		int str = 0;
		for (int j = 0; j < t; j++)
		{
			if (a[j] != m)
			{
				sum += str / k;
				str = 0;
			}
			else
			{
				str++;
			}
		}
		sum += str / k;
		MAX = max(sum, MAX);
	}
	cout << MAX << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
char a[200100];
int c[26];
int main()
{
    int n,k;
    cin>>n>>k;
    int cnt=0;
    if(k==1)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            c[a[i]-'a']++;
        }
    }
    else
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)
            {
                cnt=1;
                continue;
            }
        else
        {
          if(a[i]==a[i-1])
          {
              cnt++;
              if(cnt==k)
              {
                  c[a[i]-'a']++;
                  cnt=0;
              }
          }
          else
            cnt=1;
        }
    }
    int maxn=0;
    for(int i=0;i<26;i++)
    {
        if(maxn<c[i])
            maxn=c[i];
    }
    cout<<maxn;
}


#include<iostream>
#include<string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
string s,s1;
string ss;
int a[200003];
int main()
{
	int n, k, count, maxcount=0;
	cin >> n >> k;
	cin >> s;
	for (char c = 'a'; c <= 'z'; c++)
	{
		memset(a,0,sizeof(a));
		count = 0;
		if (s[0] == c) a[0] = 1;
		for (int i = 1; i < n; i++)
			if (s[i] == c)
			{
				a[i] = a[i - 1] + 1;
			}
			else
				a[i] = a[i - 1];
		int i = 0;
		if (a[k - 1] == k)
		{
			count++;
			i = k - 1;
		}
		for (; i < n - k;)
			if (a[i + k] - a[i] == k)
			{
				count++;
				i = i + k;
			}
			else
				i++;
		if (count > maxcount)
			maxcount = count;
	}
	cout << maxcount;
	return 0;
}


#include<iostream>
#include<string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
string s,s1;
string ss;
int main()
{
	int n, k, count, maxcount=0;
	cin >> n >> k;
	cin >> s;
	for (char c = 'a'; c <= 'z'; c++)
	{
		ss = "";
		count = 0;
		for (int i = 1; i <= k; i++)
			ss = ss + c;
		s1 = s;
		while (s1.find(ss) != -1)
		{
			count++;
			s1.erase(s1.find(ss), k);
		}
		if (count > maxcount)
		{
			maxcount = count;
		}
	}
	cout << maxcount;
	return 0;
}


#include<iostream>
#include<string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
	string s;
	int n, k, count, maxcount=0;
	cin >> n >> k;
	cin >> s;
	for (char c = 'a'; c <= 'z'; c++)
	{
		string ss = "";
		count = 0;
		for (int i = 1; i <= k; i++)
			ss = ss + c;
		string s1 = s;
		while (s1.find(ss) != -1)
		{
			count++;
			s1.erase(s1.find(ss), k);
		}
		if (count > maxcount)
		{
			maxcount = count;
		}
	}
	cout << maxcount;
	return 0;
}


#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	int n, k;
	string str;
	char input[200001];
	int seq[26] = { 0, };
	int cnt[26] = { 0, };
	int i;
	int max = 0;
	char prev;

	scanf("%d %d", &n, &k);

	scanf("%s", input);

	str = input;

	prev = str[0];

	for (i = 0; i < n; i++)
	{
		if (str[i] != prev)
		{
			cnt[prev - 'a'] = 0;
		}

		cnt[str[i] - 'a']++;

		seq[str[i] - 'a'] += cnt[str[i] - 'a'] / k;

		cnt[str[i] - 'a'] %= k;

		prev = str[i];
	}

	for (i = 0; i < 26; i++)
	{
		if (seq[i] > max)
		{
			max = seq[i];
		}
	}

	printf("%d\n", max);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define jh(x,y) x^=y^=x^=y
#define rg register
#define inl inline
typedef long long ll;
const int N = 2e5 + 5;
using namespace std;
namespace fast_IO {
    inl ll read()
    {
        rg ll num = 0;
        rg char ch;
        rg bool flag = false;
        while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
        if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
        while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
            num = (num << 1) + (num << 3) + (ch ^ 48);
        if (flag)return -num; return num;
    }
    inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
    inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
    void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
char s[N];
int num[300], a[300];

int main(void)
{
    rg int n = fast_IO::read(), k = fast_IO::read();
    scanf("%s", s + 1);
    for (rg int i = 1; i <= n; ++i)
    {
        if (++num[s[i]] == k)
        {
            num[s[i]] = 0;
            ++a[s[i]];
        }
        else if (s[i] != s[i - 1])num[s[i - 1]] = 0;
    }
    rg int maxn = 0;
    for (rg int i = 'a'; i <= 'z'; ++i)maxn = fast_IO::max(maxn, a[i]);
    fast_IO::write(maxn);
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
string s;
long long int n,k,ans[305];
int main(){
	cin>>n>>k>>s;
	int i=0;
	while(i<n)
	{
		int t=1;
		while(s[i]==s[i+1] && i<n && t<k)
		{
			t++;
			i++;
		}
		if(t==k)ans[s[i]]++;
		i++;
	}
	int a=0;
	for(int i=1;i<=300;i++)if(ans[i]>a)a=ans[i];
	cout<<a;
}


#include <iostream>
#include <cmath>
using namespace std;
string s;
long long int n,k,ans[305];
int main(){
	cin>>n>>k;
	cin>>s;
	int i=0;
	while(i<n)
	{
		int t=1;
		while(s[i]==s[i+1] && i<n && t<k)
		{
			t++;
			i++;
		}
		if(t==k)
		{
			int c=(int)s[i];
			ans[c]++;
		}
		i++;
	}
	int a=0;
	for(int i=1;i<=300;i++)if(ans[i]>a)a=ans[i];
	cout<<a;
}


#include <string>
#include <iostream>
#include <cmath>
using namespace std;
string s;
long long int n,k,ans[305];
int main(){
	cin>>n>>k;
	cin>>s;
	int i=0;
	while(i<n)
	{
		int t=1;
		while(s[i]==s[i+1] && i<n && t<k)
		{
			t++;
			i++;
		}
		if(t==k)
		{
			int c=(int)s[i];
			ans[c]++;
		}
		i++;
	}
	int a=0;
	for(int i=1;i<=300;i++)if(ans[i]>a)a=ans[i];
	cout<<a;
}


#include <bits/stdc++.h>
#include <cmath>
using namespace std;
string s;
long long int n,k,ans[305];
int main(){
	cin>>n>>k;
	cin>>s;
	int i=0;
	while(i<n)
	{
		int t=1;
		while(s[i]==s[i+1] && i<n && t<k)
		{
			t++;
			i++;
		}
		if(t==k)
		{
			int c=(int)s[i];
			ans[c]++;
		}
		i++;
	}
	int a=0;
	for(int i=1;i<=300;i++)if(ans[i]>a)a=ans[i];
	cout<<a;
}


#include <cstdio>
#include <cstring>
using namespace std;

const int NN = 220000;
int a[30], x, n, min1, ans, k, tmp;
char str1[NN], c;
bool f;

int main(){
	//freopen("a.in", "r", stdin);

	scanf("%d%d", &n, &k);
	scanf("%s", str1);

	for (int i=1; i<=26; i++){
		a[i] = 0;
		c = i - 1 + 'a';
		x = 0;
		while (x <= n-1){
			if (str1[x] == c){
				f = true;
				for (int j=x+1; j<=x+k-1; j++)
					if (str1[j] != c){
						x = j + 1;
						f = false;
						break;
					}
				if (f) {
					a[i]++;
					x += k;
				}
			}
			else x++;
		}
	}

	ans = 0;
	for (int i=1; i<=26; i++)
		if (a[i] > ans) ans = a[i];

	printf("%d", ans);

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
char s[200010];
int main()
{
	int i,j,n,k,ans[30]={0},max1=0;
	int len=1;
	scanf("%d%d",&n,&k); getchar();
	for(i=0;i<n;i++) scanf("%c",&s[i]);
	//printf("%s\n",s);
	if(k!=1)
	for(j=0;j<26;j++)
		for(i=0;i<n;i++)
		{
			if(s[i]==s[i+1]&&s[i]=='a'+j) len++;
			else len=1;
			if(len==k&&s[i]=='a'+j)
			{
				len=1;
				ans[j]++;
				i++;
			}
		}
	else for(i=0;i<n;i++)
	ans[s[i]-'a']++;
	max1=ans[0];
	for(i=1;i<26;i++)
      if(max1<ans[i])
		max1=ans[i];
	cout<<max1<<endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#define ll long long int
#define ld long double
const ll mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
	long long int i, j, k, m, n, a[1050], t;
	char s[210500];
	ll r;
	char q;
	ll ans = 0;
	cin >> n >> k;
	cin >> s;
	for (j = 0; j < 26; j++)
	{

		t = 0;
		i = 0;
		q = 'a' + j;

		while (i < n)
		{
			if (s[i] == q)
			{
				bool g = true;
				for(r=i;r<i+k;r++)
					if (s[r] != q)
					{
						g = false;
						break;
					}
				if (g == true)
				{
					t++;
					i += k;
				}
				else
					i++;

			}
			i++;
		}
		//cout << t << endl;

		ans = max(ans, t);
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#define ll long long int
#define ld long double
const ll mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
	long long int i, j, k, n, b[28], t;
	char s[210500];
	ll r;
	char q;
	ll ans = 0;
	cin >> n >> k;
	cin >> s;
	for (j = 0; j < 26; j++)
	{

		t = 0;
		i = 0;
		q = 'a' + j;
		while (i < n)
		{
			bool w = false;
			if (s[i] == q)
			{
				bool g = true;
				for (r = i; r < i + k; r++)
					if (s[r] != q)
					{
						g = false;
						break;
					}
				if (g == true)
				{
					w = true;
					t++;
					i = r;
				}
			}
			if(w==false)
				i++;
		}
		b[j] = t;
	}

	sort(b, b + 26);
	cout << b[25] << endl;
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#define ll long long int
#define ld long double
const ll mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
	long long int i, j, k, n, b[28], t;
	char s[210500];
	ll r;
	char q;
	ll ans = 0;
	cin >> n >> k;
	cin >> s;
	for (j = 0; j < 26; j++)
	{

		t = 0;
		i = 0;
		q = 'a' + j;
		while (i < n)
		{
			if (s[i] == q)
			{
				bool g = true;
				for (r = i; r < i + k; r++)
					if (s[r] != q)
					{
						g = false;
						break;
					}
				if (g == true)
					t++;

				i = r;
			}
			else
				i++;
		}
		b[j] = t;
	}

	sort(b, b + 26);
	cout << b[25] << endl;
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#define ll long long int
#define ld long double
const ll mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
	long long int i, j, k, n, b[28], t;
	char s[210500];
	ll r;
	char q;
	ll ans = 0;
	cin >> n >> k;
	cin >> s;
	for (j = 0; j < 26; j++)
	{

		t = 0;
		i = 0;
		q = 'a' + j;
		while (i < n)
		{
			bool w = false;
			if (s[i] == q)
			{
				bool g = true;
				for (r = i; r < i + k; r++)
					if (s[r] != q)
					{
						g = false;
						break;
					}
				if (g == true)
				{
					w = true;
					t++;
					i += r;
				}
			}
			if(w==false)
				i++;
		}
		b[j] = t;
	}

	sort(b, b + 26);
	cout << b[25] << endl;
	///system("pause");
	return 0;
}


#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;

char s[200010];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	s[n+1]='#';s[n+2]=0;
	int ans=0;
	for(char ch='a';ch<='z';ch++){
		int st=-1,tmp=0;
		for(int i=1;i<=n+1;i++){
			if(s[i]==ch&&st==-1){
				st=i;
			}else if(s[i]!=ch){
				if(st!=-1){
					tmp+=(i-st)/k;
					st=-1;
				}
			}
		}
		ans=max(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <string>
#include <cmath>
#include <cmath>

#define PI 3.14159265

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	string str;
	cin >> str;
	vector <int> arr(200);
	vector <int> a(200);
	int cnt = (int)str[0];
	arr[cnt]++;
	if (arr[cnt] % k==0)
	{
		arr[cnt] -= k;
		a[cnt]++;

	}
	for (int i = 1; i < n; i++)
	{
		int cnt1 = (int)str[i-1];
		int cnt = (int)str[i];
		if (cnt != cnt1)
		{
			for (int i = 60; i < 130; i++)
			{
				arr[i] = 0;
			}
		}
		arr[cnt]++;
		//cout << arr[cnt] << " ";
		if (arr[cnt] % k==0)
		{
			arr[cnt] -= k;
			a[cnt]++;
			//cout << a[cnt] << " ";

		}
	}
	int m = 0;
	for (int i = 0; i < 200; i++)
	{
		m = max(m, a[i]);
	}
	cout << m;
//	system("pause");
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;

char str[200001];

int calc(int n, int k, char c){
	int cnt = 0;
	int begin = 0;

	for (int now = 0; now <= n; now++){
		if (str[now] != c){
			cnt += (now - begin) / k;
			begin = now + 1;
		}
	}
	return cnt;
}

int main()
{
	int n, k, maxv;
	scanf("%d %d\n", &n, &k);
	scanf("%s", str);
	maxv = 0;

	for (int i = 0; i < 26; i++)
		maxv = max(maxv, calc(n, k, 'a' + i));
	printf("%d\n", maxv);
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;

char str[200001];

int calc(int n, int k, char c){
	int cnt = 0;
	int begin = 0;

	for (int now = 0; now < n; now++){
		if (str[now] != c){
			cnt += (now - begin) / k;
			begin = now + 1;
		}
	}
	return cnt;
}

int main()
{
	int n, k, maxv;
	scanf("%d %d\n", &n, &k);
	scanf("%s", str);
	maxv = 0;

	for (int i = 0; i < 26; i++)
		maxv = max(maxv, calc(n, k, 'a' + i));
	printf("%d\n", maxv);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace::std;

char str[200005];
int main()
{
	long long n, k;
	scanf("%lld %lld", &n, &k);

	scanf("%s", str);

	int level[30];
	memset(level, 0, sizeof level);
	for (int i = 0; i < n; i++)
	{
		bool isSub = true;
		for (int j = 0; j < k; j++)
		{
			if (str[i] != str[i + j])
			{
				isSub = false;
				break;
			}
		}

		if (isSub)
		{
			level[str[i] - 'a']++;
			i += k - 1;
		}
	}

	int maximum = 0;
	for (int i = 0; i < 30; i++)
	{
		maximum = max(maximum, level[i]);
	}
	printf("%d", maximum);
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace::std;

char str[200005];
int main()
{
	long long n, k;
	scanf("%lld %lld", &n, &k);

	scanf("%s", str);

	int level[30];
	memset(level, 0, sizeof level);
	for (int i = 0; i < n; i++)
	{
		int j = 0;
		for (; j < k; j++)
		{
			if (str[i] != str[i + j])
			{
				break;
			}
		}

		if (j == k)
		{
			level[str[i] - 'a']++;
		}
		i += j - 1;
	}

	int maximum = 0;
	for (int i = 0; i < 30; i++)
	{
		maximum = max(maximum, level[i]);
	}
	printf("%d", maximum);
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	int n, k, brojac;
	int razina[500];
	char niz[300000];

	for(int i = 0; i < 500; i++){
        razina[i] = 0;
	}

	cin >> n;
	cin >> k;

	cin >> niz;

	char pom = niz[0];
	brojac = 0;

	for(int i = 0; i < n; i++){

        if(niz[i] == pom){
            brojac++;
            if(brojac == k){
                brojac = 0;
                if(i < n - 1){
                    pom = niz[i + 1];
                }
                int hlp = niz[i];
                razina[hlp]++;
            }
        }else{
            brojac = 0;
            pom = niz[i];
            i--;
        }

	}

	sort(razina, razina + 500);
	cout << razina[499];

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	int n, k, brojac;
	int razina[500];
	char niz[300000];

	for(int i = 0; i < 500; i++){
        razina[i] = 0;
	}

	cin >> n;
	cin >> k;

	cin >> niz;

	char pom = niz[0];
	brojac = 0;

	for(int i = 0; i < n; i++){

        if(niz[i] == pom){
            brojac++;
            if(brojac == k){
                brojac = 0;
                if(i < n - 1){
                    pom = niz[i + 1];
                }
                int hlp = niz[i];
                razina[hlp]++;
            }
        }else{
            brojac = 0;
            pom = niz[i];
            i--;
        }

	}

	sort(razina, razina + 500);
	cout << razina[500];

	return 0;
}


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
int main()
{
    map<char,int>xyh;
    int d[200001],n,k,m=0;
  char c[200001];
  memset(d,0,sizeof(d));
  cin>>n>>k;
  for(int i=0;i<n;i++)
    {
        d[i]=1;
        cin>>c[i];
  if(i>=1&&c[i]==c[i-1]) d[i]=d[i-1]+1;
  if(d[i]==k)
  {
      xyh[c[i]]++;m=max(m,xyh[c[i]]);
  }
    }
    cout<<m;
    return 0;

}


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
int main()
{
    map<char,int>xyh;
    int d[200001],n,k,m=0;
  char c[200001];
  memset(d,0,sizeof(d));
  cin>>n>>k;
  for(int i=0;i<n;i++)
    {
        d[i]=1;
        cin>>c[i];
  if(i>=1&&c[i]==c[i-1]) d[i]=d[i-1]+1;
  if(d[i]==k)
  {
      xyh[c[i]]++;m=max(m,xyh[c[i]]);
      d[i]=0;
  }
    }
    cout<<m;
    return 0;
}


#include <iostream>
using namespace std;
int main() {
	int n, k;
	char s[200001];
	int value[26] = {0}, cnt = 0;
	cin >> n >> k >> s;
	int i, j;
	for(i=0; i<n; i+=k) {
		int flag = 1;
		for(j=i; j<i+k-1; j++) {
			if(s[j] != s[j+1]) {
				flag = 0;
				break;
			}
		}
		if(flag == 1 && j==i+k-1) {
			value[s[i]-'a']++;
			cnt = max(value[s[i]-'a'], cnt);
		}
	}
	cout << cnt << endl;
	return 0;
}


/*#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
map<int, int>m;
int main() {
	int n;
	cin >> n;
	int a[10002];
	int i, j, cnt=0;
	for(i=0; i<n; i++)
		cin >> a[i];
	for(i=0; i<n; i++) {
		for(j=i+1; j<n; j++) {
			int sum = a[i] + a[j];
			if(m.count(sum) == 0) {
				m[sum]=1;
			}
			else
				m[sum]++;
			cnt = max(m[sum], cnt);
		}
	}
	cout << cnt << endl;
	return 0;
}*/
#include <iostream>
using namespace std;
int main() {
	int n, k;
	char s[200001];
	int value[26] = {0}, cnt = 0;
	cin >> n >> k >> s;
	int i;
	for(i=0; i<n; i+=k) {
		int flag = 1;
		for(int j=0; j<k-1; j++) {
			if(s[i] != s[i+1]) {
				flag = 0;
				break;
			}
		}
		if(flag == 1) {
			value[s[i]-'a']++;
			cnt = max(value[s[i]-'a'], cnt);
		}
	}
	cout << cnt << endl;
	return 0;
}


#include <iostream>
using namespace std;
int main() {
	int n, k;
	char s[200001];
	int value[26] = {0}, cnt = 0, ans = 1;
	cin >> n >> k >> s;
	int i, j;
	for(i=0; i<n; i++) {
		if(k==1) {
			value[s[i]-'a']++;
			cnt = max(value[s[i]-'a'], cnt);
		}
		else{
			if(s[i] == s[i+1]) {
				ans++;
			}
			else
				ans=1;
			if(ans == k) {
				value[s[i]-'a']++;
				cnt = max(value[s[i]-'a'], cnt);
				ans=1;
				i+=1;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll oo = 1e18;
ll const M = 1e6, N = 3e5 + 7;
ll  n, m, sum, t, c, k;
ll x, y;
vector<int>v;
int f[27];
int main()
{
	matar
		string s;
	cin >> n >> k >> s;
	c = 1;
	loop(n - 1)
	{

		if (s[i] == s[i + 1])c++;

		if (c == k){
			f[s[i] - 'a']++;
			c = 1;
			i ++;
			//	cout << f[0] <<i<<" "<< endl;
		}

	}
	int c = 0;
	loop(27)c = max(c, f[i]);
	re(c);
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll oo = 1e18;
ll const M = 1e6, N = 3e5 + 7;
ll  n, m, sum, t, c, k;
ll x, y;
vector<int>v;
int f[27];
int main()
{
	matar
		string s;
		cin >> n>>k>>s;
		c = 1;
		loop(n-1)
		{

			if (s[i] == s[i + 1])c++;

			 if (c == k){
				f[s[i]-'a']++;
				c = 1;
				i += 2;
			//	cout << f[0] <<i<<" "<< endl;
			}

		}
		int c = 0;
		loop(27)c = max(c, f[i]);
		re(c);
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll oo = 1e18;
ll const M = 1e6, N = 3e5 + 7;
ll  n, m, sum, t, c, k;
ll x, y;
vector<int>v;
int f[27];
int main()
{
	matar
		string s;
	cin >> n >> k >> s;
	c = 1;
for(int i=1;i<n;i++)
{

		if (s[i] == s[i - 1])c++;
		else if (c == k){
			f[s[i-1] - 'a']+=c/k;
			c = 1;
			//	cout << f[0] <<i<<" "<< endl;
		}

	}
	f[s[n - 1] - 'a'] += c / k;
	int c = 0;
	loop(27)c = max(c, f[i]);
	re(c);
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll oo = 1e18;
ll const M = 1e6, N = 3e5 + 7;
ll  n, m, sum, t, c, k;
ll x, y;
vector<int>v;
int f[27];
int main()
{
	matar
		string s;
	cin >> n >> k >> s;
	c = 1;
for(int i=1;i<n;i++)
{

		if (s[i] == s[i - 1])c++;
		else {
			f[s[i-1] - 'a']+=c/k;
			c = 1;
			//	cout << f[0] <<i<<" "<< endl;
		}

	}
	f[s[n - 1] - 'a'] += c / k;
	int c = 0;
	loop(27)c = max(c, f[i]);
	re(c);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,k,i,j;
    while(~scanf("%d%d",&n,&k))
    {
        char a[200005];
        int cnt[27]={0};
        int Max=0;
        int cot = 1;
        scanf("%s",a);
        for(i=1;i<n;i++)
        {
           if(a[i - 1] == a[i])
           {
               cot++;
           }
           else
           {
                if(cot >= k)
                {
                    cnt[a[i-1]-97]+=cot/k;
                }
                cot=1;
           }
        }
        for(i=0;i<26;i++)
        {
            if(Max<cnt[i])
                Max=cnt[i];
        }
        printf("%d\n",Max);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,k,i,j;
    while(~scanf("%d%d",&n,&k))
    {
        char a[200000];
        int cnt[26]={0};
        int Max=0;
        scanf("%s",a);
        for(i=0;i<n;i++)
        {
            for(j=0;j<k-1;j++)
            {
                if(a[j+i]!=a[j+1+i])
                break;
            }
            if(j==k-1)
            {
            cnt[a[i]-97]++;
            i+=k-1;
            }
        }
        for(i=0;i<26;i++)
        {
            if(Max<cnt[i])
                Max=cnt[i];
        }
        printf("%d\n",Max);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,k,i,j;
    while(~scanf("%d%d",&n,&k))
    {
        char a[200005];
        int cnt[27]={0};
        int Max=0;
        int cot = 1;
        scanf("%s",a);
        for(i=1;i<n;i++)
        {
           if(a[i - 1] == a[i])
           {
               cot++;
           }
           else
           {
                if(cot >= k)
                {
                    cnt[a[i-1]-97]+=cot/k;
                }
                cot=1;
           }
        }
        cnt[a[i-1]-97]+=cot/k;
        for(i=0;i<26;i++)
        {
            if(Max<cnt[i])
                Max=cnt[i];
        }
        printf("%d\n",Max);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,k,i,j;
    while(~scanf("%d%d",&n,&k))
    {
        char a[200005];
        int cnt[27]={0};
        int Max=0;
        scanf("%s",a);
        for(i=0;i<n;i++)
        {
            for(j=0;j<k-1;j++)
            {
                if(a[j+i]!=a[j+1+i])
                break;
            }
            if(j==k-1)
            {
            cnt[a[i]-97]++;
            i+=k-1;
            }
        }
        for(i=0;i<26;i++)
        {
            if(Max<cnt[i])
                Max=cnt[i];
        }
        printf("%d\n",Max);
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    int ma = 0;
    for (int i = 0; i < 26; i++)
    {
        int su = 0;
        int j = 0;
        while (j + k <= n)
        {
            int cnt = 0;
            for (int l = j; l < j + k; l++)
            {
                if (s[l] == ('a' + i))
                    cnt++;
                else
                    break;
            }
            if (cnt == k)
            {
                su++;
                j += k;
            }
            else
            {
                j++;
            }
        }
        if (su > ma)
            ma = su;
    }
    cout << ma;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    int ma = 0;
    for (int i = 0; i < 26; i++)
    {
        int su = 0;
        int j = 0;
        while (j + k <= n)
        {
            int cnt = 0;
            for (int l = j; l < j + k; l++)
            {
                if (s[l] == ('a' + i))
                    cnt++;
                else
                    break;
            }
            if (cnt == k)
            {
                su++;
                j += k;
            }
            else
            {
                j += cnt + 1;
            }
        }
        if (su > ma)
            ma = su;
    }
    cout << ma;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char x[200005];
int y[30];
int z[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	scanf("%s",x);
	if(k==1)
	{
		for(int a=0;a<n;a++)
		{
			y[x[a]-'a']++;
		}
	}
	else
	{
	int b=1;
	z[0]=1;
	while(b<n)
	{
		if(x[b]==x[b-1])
		{
			z[b]=z[b-1]+1;
			if(z[b]==k)
			{
				y[x[b]-'a']++;
				z[b]=0;
			}
		}
		else
		z[b]=1;
		b++;
	}
	}
	int M=0;
	for(int c=0;c<26;c++)
	{
		if(y[c]>M)
		M=y[c];
	}
	cout<<M;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char x[200005];
int y[30];
int main()
{
	int n,k;
	cin>>n>>k;
	scanf("%s",x);
	int a;
	a=strlen(x);
	int b=0;
	while(b<a)
	{
		if(x[b]==x[b+1])
		{
			y[x[b]-'a']++;
			b++;
		}
		b++;
	}
	int M=0;
	for(int c=0;c<26;c++)
	{
		if(y[c]>M)
		M=y[c];
	}
	cout<<M;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
char a[200001];
int main()
{
	int n, k;
	int d[129] = {};
	cin >> n >> k;
	int top = 1;
	int span = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (top)
		{
			if (a[i] == a[i - 1])
			{
				top++;
			}
			else
				top = 0;
		}
		if (top == 0)
		{
			top = 1;
		}
		if (top == k)
		{
			d[a[i]]++;
			top = 0;
		}
	}
	sort(d + 96, d + 129);
	cout << d[128] << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
char a[200001];
int main()
{
	int n, k;
	int d[129] = {};
	cin >> n >> k;
	int top = 1;
	int span = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (top)
		{
			if (a[i] == a[i - 1])
			{
				top++;
			}
		}
		if (top == 0)
		{
			top = 1;
		}
		if (top == k)
		{
			d[a[i]]++;
			top = 0;
		}
	}
	sort(d + 96, d + 129);
	cout << d[128] << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
char a[200000];
int bk[129];
int main()
{
	int n,k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i + k -1< n; i++)
	{
			int p = 0;
			for (int j = 1; j <k; j++)
			{
				if (a[j + i] != a[i])
				{
					p = 1;
					break;
				}
			}
			if (p == 0)
			{
				bk[a[i]]++;
				i += k-1;
			}
			if (bk[a[i]] >= n / k)
				break;
	}
	sort(bk + 97, bk + 129);
	cout << bk[128] << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
char a[200000];
int bk[129];
int main()
{
	int n,k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i + k -1< n; i++)
	{
			int p = 0;
			if (a[i + 1] == a[i] && a[i + k - 1] == a[i])
			{
				for (int j = 2; j < k; j += 2)
				{
					if (a[j + i] != a[i] || a[j + i + 1] != a[i])
					{
						p = 1;
						break;
					}
				}
				if (p == 0)
				{
					bk[a[i]]++;
					i += k - 1;
				}
				if (bk[a[i]] >= n / k)
					break;
			}
	}
	sort(bk + 97, bk + 129);
	cout << bk[128] << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
char a[200000];
int bk[129];
int main()
{
	int n,k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i + k -1< n; i++)
	{
			int p = 0;
			for (int j = 1; j <k; j++)
			{
				if (a[j + i] != a[i])
				{
					p = 1;
					break;
				}
			}
			if (p == 0)
			{
				bk[a[i]]++;
				i += k-1;
			}
	}
	sort(bk + 97, bk + 129);
	cout << bk[128] << endl;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <string.h>
#include <algorithm>
#include <utility>
#include <assert.h>
using namespace std;
typedef _int64 ll;
const int inf=0x3f3f3f3f;
const int maxn = 1010;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a>b?b:a;}
int a[maxn];
int main()
{
#ifdef _DEBUG
    freopen("in.txt","r",stdin);
#endif
	int n,k,i,j;
	string s;
	while(cin>>n>>k)
	{
		cin>>s;
		int maxi=0;
		for( i = 0 ; i < 26 ; i++)
		{
			char c = 'a'+i;
			int ans=0;
			for( j = 0 ; j < n ; )
			{
				int cnt=0;
				if(c==s[j])
				{
					while(s[j]==c)
					{
						cnt++;
						j++;
					}
					ans+=cnt/k;
				}
				else j++;
			}
			maxi=max(ans,maxi);
		}
		cout<<maxi<<endl;
	}
    return 0;
}


#define _USE_MATH_DEFINES

#include <iostream>
#include <vector>
#include <algorithm>
#include<map>
#include<cmath>
#include<string>
#include<set>
#include<iterator>
#include<queue>
#include <math.h>

using namespace std;

int main() {
     int n,k;
     string s;

     cin>>n>>k;
     cin>>s;

     int maxx=0,count=0,d=0;

     for (char c='a';c<='z';c++){

          for (int i=0;i<n;i++){

               if (s[i]==c){count++;}else{count=0;}

               if (count==k){d++;count=0;}

          }
          maxx=max(maxx,d);
          d=0;
     }

     cout<<maxx;
}


#include<cstdio>
#include<algorithm>
using namespace std;
char x[200005];
int tong[26];
int main()
{
	int cnt=0;
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",x);
	int now=0;
	while(now<=n)
	{
		bool you=true;
		for(int i=1;i<k;++i)
			if(x[now+i]!=x[now])
			{
				you=false;
				now+=i;
				break;
			}
		if(you)
		{
			++tong[x[now]-'a'];
			cnt=max(cnt,tong[x[now]-'a']);
			now+=k;
		}
	}
	printf("%d",cnt);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
char x[200005];
int tong[26];
int main()
{
	int cnt=0;
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%c",&x[i]);
	int now=1;
	while(now<=n)
	{
		bool you=true;
		for(int i=1;i<k;++i)
			if(x[now+i]!=x[now])
			{
				you=false;
				now+=i;
				break;
			}
		if(you)
		{
			++tong[x[now]-'a'];
			cnt=max(cnt,tong[x[now]-'a']);
			now+=k;
		}
	}
	printf("%d",cnt);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
char x[200005];
int tong[26];
int main()
{
	int cnt=0;
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",x);
	int now=0;
	while(now<n)
	{
		bool you=true;
		for(int i=1;i<k;++i)
			if(x[now+i]!=x[now])
			{
				you=false;
				now+=i;
				break;
			}
		if(you)
		{
			++tong[x[now]-'a'];
			cnt=max(cnt,tong[x[now]-'a']);
			now+=k;
		}
	}
	printf("%d",cnt);
	return 0;
}


#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <vector>
#define ll long long
using namespace std;
const int maxn = 100009, INF = 1000000009;
map <char, int> ans;
int main()
{
	int n, how, k;
	char a, l='0';
	cin >> n >> k;
	for (int i=0; i<n; i++)
	{
		cin >> a;
		if (l == a)
			how++;
		else
		{
			how = 1;
			l = a;
		}
		if (how == k)
		{
			ans[a] ++;
			how = 0;
			l = a;
		}
	}
	how = 0;
	for (char i = 'a'; i<='z'; i++)
		how = max(how, ans[i]);
	cout << how;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <memory.h>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#pragma comment(linker, "/STACK:667177216")
#define ll long long
#define ull unsigned long long
#define INF 1000000007;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define vI vector<int>
#define vvI vector<vector<int>>
#define vLL vector<LL>
#define vS vector<string>
#define fori(i, n) for (int(i) = 0; (i) < n; (i)++)
#define forn(it, from, to) for (int(it) = from; (it) < to; (it)++)
#define forI(tmp) for (auto(it) = (tmp).begin(); (it) != (tmp).end(); (it)++)
#define PI 3.14159265356
#define LD long double
#define sc(a) scanf("%d", &(a))
#define scLL(a) scanf("%I64d", &(a))
#define mems(a, val) memset(a, val, sizeof(a))
#define sz(a) (int)(a).size()
typedef long long LL;
using namespace std;
const LL MOD = 1000000000 + 7;
const LL MAXN = 100000 + 100;

int main()
{
#ifdef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;

    int maxi = 0;
    vector<int> count(26);
    for(int i = 0; i < n; ++i) {
        int v = i;
        while(v < n && s[v] == s[i]) {
            v++;
        }

        int len = v - i;
        //cout<<len<<endl;
        count[s[i] - 'a'] += len / k;
        maxi = max(maxi, count[s[i] - 'a']);
        i = v - 1;
    }

    cout<<maxi;

    return 0;
}


#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
    int n, k;
    cin>>n>>k;

    char *a = new char [n];

    int tmplen=0;
    unordered_map<char, int> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    char prev;
    for(int i=0;i<n;i++){
        if(i==0){
            prev=a[i];
            tmplen++;
            if(tmplen == k){
                m[a[i]]++;
                tmplen=0;
            }
        }
        else{
            if(tmplen!=0){
                if(a[i]==prev){
                    tmplen++;
                    if(tmplen == k){
                        m[a[i]]++;
                        tmplen=0;
                    }
                }
                else{
                    tmplen=0;
                }
            }
            else{
                tmplen++;
                if(tmplen == k){
                    m[a[i]]++;
                    tmplen=0;
                }
            }
            prev=a[i];
        }
    }
    int max=INT_MIN;
    for (unordered_map<char,int>::iterator it=m.begin(); it!=m.end(); ++it)
    {
        if(it->second > max){
            max=it->second;
        }
    }

    if(max ==INT_MIN){
        cout<< '0';
    }
    else{
        cout<<max;
    }

    return 0;
}


#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
    int n, k;
    cin>>n>>k;

    char *a = new char [n];

    int tmplen=0;
    unordered_map<char, int> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    char prev;
    for(int i=0;i<n;i++){
        if(i==0){
            prev=a[i];
            tmplen++;
            if(tmplen == k){
                m[a[i]]++;
                tmplen=0;
            }
        }
        else{
            if(tmplen!=0){
                if(a[i]==prev){
                    tmplen++;
                    if(tmplen == k){
                        m[a[i]]++;
                        tmplen=0;
                    }
                }
                else{
                    tmplen=1;
                }
            }
            else{
                tmplen++;
                if(tmplen == k){
                    m[a[i]]++;
                    tmplen=0;
                }
            }
            prev=a[i];
        }
    }
    int max=INT_MIN;
    for (unordered_map<char,int>::iterator it=m.begin(); it!=m.end(); ++it)
    {
        if(it->second > max){
            max=it->second;
        }
    }

    if(max ==INT_MIN){
        cout<< '0';
    }
    else{
        cout<<max;
    }

    return 0;
}


#include <cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int i,j,n,m,b[100];
char a[200010];
int main(){
    while(cin>>n>>m){
        memset(b,0,sizeof(b));
        cin>>a;
        for(i=0;i<n-1;i++){
            if(a[i]==a[i+1]){
                for(j=1;j+i<n;j++)
                    if(a[i]!=a[j+i])
                        break;
                b[a[i]-'a']+=j/m;
                i+=(j-1);
            }
        }
        int maxm=0;
        if(m==1)
            maxm=1;
        for(i=0;i<30;i++)
            if(b[i]>maxm)
                maxm=b[i];
        cout<<maxm<<endl;
    }
    return 0;
}


#include <cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int i,j,n,m,b[100];
char a[200010];
int main(){
    while(cin>>n>>m){
        memset(b,0,sizeof(b));
        gets(a);
        for(i=0;i<n-1;i++){
            if(a[i]==a[i+1]){
                for(j=1;j+i<n;j++)
                    if(a[i]!=a[j+i])
                        break;
                b[a[i]-'a']+=j/m;
                i+=(j-1);
            }
        }
        int maxm=0;
        for(i=0;i<30;i++)
            if(b[i]>maxm)
                maxm=b[i];
        cout<<maxm<<endl;
    }
    return 0;
}


#include <cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int i,j,n,m,b[100];
char a[200010];
int main(){
    while(cin>>n>>m){
        memset(b,0,sizeof(b));
        cin>>a;
        for(i=0;i<n-1;i++){
            if(a[i]==a[i+1]){
                for(j=1;j+i<n;j++)
                    if(a[i]!=a[j+i])
                        break;
                b[a[i]-'a']+=j/m;
                i+=(j-1);
            }
        }
        int maxm=0;
        for(i=0;i<30;i++)
            if(b[i]>maxm)
                maxm=b[i];
        cout<<maxm<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
      int n, k, maxCount = 0;
      string s;
      cin >> n >> k;
      cin >> s;
      for (int i = 0; i < n - k; i++)       // для полного перебора осн. подстрок
      {
            int count = 0;
            for (int j = i; j < n - k; j++) // для сравнения всех слов
            {
                int similar = 0;
                for (int q = j; q < j + k; q++)
                    if (s[i] == s[q])
                        similar++;
                if (similar == k)
                {
                    count++;
                    j++;                             // пропускаем один символ
                }
            }
            if (maxCount < count) maxCount = count;
      }
      cout << maxCount;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, k, result = 0;
    string s;
    cin >> n >> k >> s;
    for (int i = 97; i < 123; i++)
    {
        char substring = char(i);
        int countOfRepeat = 0;

        for (int j = 0; j < n - k; j++)
        {
            int left = j, right = j + k - 1, converge = true;

            while (left <= right)
            {
                if (s[left] == substring && s[right] == substring)
                {
                    left++; right--;
                } else {
                    converge = false;
                    break;
                }
            }
            if (converge)
            {
                countOfRepeat++;
                j += k - 1;
            }
        }
        if (result < countOfRepeat)
            result = countOfRepeat;
    }
    cout << result;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, k, result = 0, j = 0;
    string s;
    cin >> n >> k >> s;
    for (char c = 'a'; c <= 'z'; c++)
    {
		int x=0;
		int i=0;
		while(i < n)
		{
			if(s[i] == c)
				j++;
			else
				j = 0;
			if(j == k){
				x++;
				j = 0;
			}
			i++;
		}
		result = max(x, result);
	}
	cout<< result <<endl;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, k, result = 0;
    string s;
    cin >> n >> k >> s;
    for (int i = 97; i < 123; i++)
    {
        char substring = char(i);
        int countOfRepeat = 0;

        for (int j = 0; j < n - k + 1; j++)
        {
            int left = j, right = j + k - 1, converge = true;

            while (left <= right)
            {
                if (s[left] == substring && s[right] == substring)
                {
                    left++; right--;
                } else {
                    converge = false;
                    break;
                }
            }
            if (converge)
            {
                countOfRepeat++;
                j += k - 1;
            }
        }
        if (result < countOfRepeat)
            result = countOfRepeat;
    }
    cout << result;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int n, k;
string s;
vector<int> a;

int main(){

    cin >> n >> k;
    cin >> s;

    a.resize(26);
    for (int i = 0; i < 26; ++i)
        a[i] = 0;

    int curr_seq = 0;
    int i = 0;
    char curr_c = s[0];
    while (i < n){

        if (s[i] == curr_c){
            ++curr_seq;
        }
        else{
            curr_c = s[i];
            curr_seq = 1;
        }

        if (curr_seq == k){
            ++a[curr_c - 'a'];
            curr_seq = 0;

        }

        ++i;
    }

    cout << *max_element(a.begin(), a.end()) << endl;

    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
long long gcd(long long a, long long b) {
	if (a%b == 0) return b;
	return gcd(b, a%b);
}
char str[200005];
int main() {
	int n, k, s,j;
	scanf("%d%d", &n, &k);
	scanf("%s", str);
	char c; int max = 0;
	for (c = 'a'; c <= 'z'; c++) {
		int a = 1, f = 0;
		s = 0;
		for (int i = 0; str[i];) {
			if (str[i] == c) {
				for (j = i; j <= i+k-1; j++) {
					if (str[j] != c)
						break;
				}
				if (j > i + k - 1) {
					s++;
					i = i + k;
				}
				else {
					i = j + 1;
				}
			}
			else {
				i++;
			}

		}
		if (max < s)
			max = s;
	}
	printf("%d\n", max);
	return 0;
}


/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>
#include <stack>
#include <ctime>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(43);

const double PI = acos((double)-1);
const double eps = 1e-5;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

const int N = 7e4 + 2;

bitset<N> tmp;
bitset<N> dp;

bool used[N];
int frst[N];

int find_first() {
	for (int i = 0; i < N; i++)
		if (tmp[i])
			return i;
	return -1;
}

void solve() {
	fill(frst, frst + N, -1);
	int n, s;
	cin >> n >> s;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	for (int i = 0; i <= n; i++) {
		dp[i] = 0;
		used[i] = false;
	}
	sort(all(a));
	if (a.back().first > s) {
		cout << -1 << endl;
		return;
	}
	dp[0] = 1;
	for (int i = 1; i < n; i++) {
		int x = a[i - 1].first;
		tmp = dp;
		dp = dp | (dp << x);
		tmp = dp ^ tmp;
		while (tmp.count()) {
			int kek = tmp._Find_first();
			frst[kek] = i - 1;
			tmp[kek] = 0;
		}
	}
	if (!dp[s - a.back().first]) {
		cout << -1 << endl;
		return;
	}
	used[n - 1] = true;
	int x = s - a.back().first;
	while (x) {
		int i = frst[x];
		used[i] = true;
		x -= a[i].first;
	}
	vector<int> c(n);
	vector<vector<int>> ans(n);
	vector<pair<int, int>> kek;
	for (int i = 0; i < n - 1; i++) {
		if (used[i])
			c[a[i].second] = a[i].first;
		else
			kek.push_back(a[i]);
	}
	if (kek.empty())
		c[a.back().second] = a.back().first;
	else {
		c[kek[0].second] = kek[0].first;
		for (int i = 1; i < kek.size(); i++) {
			c[kek[i].second] = kek[i].first - kek[i - 1].first;
			ans[kek[i].second].push_back(kek[i - 1].second);
		}
		c[a.back().second] = a.back().first - kek.back().first;
		ans[a.back().second].push_back(kek.back().second);
	}
	for (int i = 0; i < n; i++) {
		cout << c[i] << " " << ans[i].size() << " ";
		for (int j : ans[i])
			cout << j + 1 << " ";
		cout << endl;
	}
	return;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 70000;

int orig[MAXN];
int arr[MAXN];
int idx[MAXN];
pair<int, int> srt[MAXN];
int pos[MAXN];
bool taken[MAXN];
vector<int> edges[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, s, i, j;
    bitset<MAXN> mask, tmp;

    cin>>n>>s;

    mask.set(0);

    for (i = 0; i < n; ++i)
    {
        cin>>orig[i];
        srt[i].first = orig[i];
        srt[i].second = i;
    }
    sort(srt, srt + n);

    for (i = 0; i < n; ++i)
    {
        tie(arr[i], idx[i]) = srt[i];
    }

    if (s < arr[n - 1])
    {
        cout<<"-1\n";
        return 0;
    }
    s -= arr[n - 1];

    for (i = 0; i < n - 1; ++i)
    {
        tmp = ~mask & (mask << arr[i]);
        for (j = tmp._Find_first(); j < MAXN; j = tmp._Find_next(j))
        {
            pos[j] = i;
        }
        mask |= tmp;
    }

    if (!mask.test(s))
    {
        cout<<"-1\n";
        return 0;
    }

    while (s != 0)
    {
        taken[pos[s]] = true;
        s -= arr[pos[s]];
    }

    for (i = 0; i < n - 1; ++i) if (!taken[i])
    {
        edges[idx[i + 1]].push_back(idx[i] + 1);
        orig[idx[i + 1]] -= arr[i];
    }

    for (i = 0; i < n; ++i)
    {
        cout<<orig[i]<<' '<<edges[i].size();
        for (int x: edges[i])
            cout<<' '<<x;
        cout<<'\n';
    }
}