N, K = gets.split.map(&:to_i) S = "o#{gets.chomp}x" MEMO = Array.new(N + 1) def min(a,b); a < b ? a : b; end def win?(n) return MEMO[min(n,N)] = true if n >= N || S[n] == 'x' return MEMO[n] unless MEMO[n].nil? MEMO[n] = !(1 .. K).all?{|i| win?(n + i) } end if win?(0) puts (1 .. K).reject{|i| MEMO[i] } else puts 0 end