import sequtils,strutils,math proc matchstr(s : string,c : char, index : int): bool = if index < 0: return false if index > s.high: return false if s[index] == c: return true else: return false var Kr,Kb : int S : string ans = 0 (Kr,Kb) = stdin.readline.split.map(parseInt) S = stdin.readline for i in 1..<(1 shl 20): var j = i ns = "" flag = true for s in S: if s == 'W': ns &= "W" else: if j mod 2 == 1: ns &= s j = j shr 1 for index,s in ns: if s == 'W': continue elif (s == 'R' and (matchstr(ns,s,index + Kr) or matchstr(ns,s,index - Kr))): flag = false break elif (s == 'B' and (matchstr(ns,s,index + Kb) or matchstr(ns,s,index - Kb))): flag = false break if flag: ans = max(ans,ns.len) echo ans