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XXWBBXBBXXBWXXWBWWBXWXXWWXXBXBWBWXWBBBWXXWXXWBWBBXWWBBWXXXBBWWXXXXBBBBBBWWBBWBWBXXWWXXBWXWWBB
 3 1
XBW
 4 1
XXXW
 100 20
WBBXWBBWWWXBXWWWWWBBBWWBWWBWWWWXWXXBWWBWXWBBXWBWBXWXWXWWBWWWBBXWWBXBBBWBXXWWBXXWWXWXWXBBBWXXWWBWBWXW
 4 1
XXWW
 20 1
XBBBWBXXBWXWWWBWWXXW
 2 1
WX
 3 1
XBX
 20 2
XXXBXWBBBBWXWWWXWWXB
 20 3
BWWWWWXBWXXXXBBWBBWX
 10 3
BXBWBWWWWX
 10 3
WWXBWXXWWW

0
 0
 0
 0
 0
 1
 10
 951778854
 135234318
 1
 0
 4
 0
 0
 0
 0
 28
 1
 817953325
 0
 0
 0
 4
 0
 1
 11
 1048576
 23240159
 126
 8
 469056403
 2
 7
 0
 3
 64
 0
 2
 128
 0
 2
 0

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;


public class D {
	int MOD = (int)1e9 + 7;
	
	void do_solve() throws NumberFormatException, IOException {
		int n = _int();
		int k = _int();
		
		char s[] = _token().toCharArray();
		
		long b[] = new long[n+1];
		long sumb[] = new long[n+1];
		long b2[] = new long[n+1];

		long w[] = new long[n+1];
		long sumw[] = new long[n+1];
		long w2[] = new long[n+1];

		long t[] = new long[n+1];
		
		t[0] = 1;
		int cnt = 0, cnt2 = 0;
		for(int i = 1; i <= n; i++) {
			t[i] = t[i-1];
			if (s[i - 1] == 'X') {
				t[i] = (t[i] * 2) % MOD;
			}
			
			if (s[i-1] != 'W') {
				cnt++;
			}
			
			if (s[i-1] == 'B') {
				cnt2++;
			}

			if (i >= k+1 && s[i-1-k] == 'B') {
				cnt2--;
			}
			
			if (i >= k+1 && s[i-k-1] != 'W') {
				cnt--;
			}
			
			b2[i] += (s[i-1] == 'X' ? 2 : 1 ) * b2[i-1];
			
			if (cnt == k) {
				b2[i] += t[i - k] - b2[i - k] - sumb[i-1] + sumb[i-k];
				b[i] += t[i - k] - b2[i - k] - sumb[i-1] + sumb[i-k];
			}
			
			b2[i] %= MOD;
			b[i] %= MOD;
			sumb[i] = (sumb[i-1] + b[i]) % MOD;
		}
		
		t[n] = 1;
		t[0] = 1;
		cnt = 0; cnt2 = 0;
		for(int i = n-1; i >= 0; i--) {
			t[i] = t[i+1];
			if (s[i] == 'X') {
				t[i] = (t[i] * 2) % MOD;
			}
			
			if (s[i] != 'B') {
				cnt++;
			}
			
			if (s[i] == 'W') {
				cnt2++;
			}

			if (i < n-k && s[i+k] == 'W') {
				cnt2--;
			}
			
			if (i < n-k && s[i+k] != 'B') {
				cnt--;
			}
			
			w2[i] += (s[i] == 'X' ? 2 : 1 ) * w2[i+1];
			
			if (cnt == k) {
				w2[i] += t[i + k] - w2[i + k] - sumw[i+1] + sumw[i+k];
				w[i] += t[i + k] - w2[i + k] - sumw[i+1] + sumw[i+k];
			}
			
			w2[i] %= MOD;
			w[i] %= MOD;
			sumw[i] = (sumw[i+1] + w[i]) % MOD;
		}
		
		long ans = 0;
		for(int i = 0; i <= n; i++) {
			ans += b[i] * w2[i];
//			debug(i, b[i], b2[i], w2[i]);
			ans %= MOD;
		}
//		debug("");
		out.println((ans + MOD) % MOD);
	}

	void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}

	void mainProgram() throws NumberFormatException, IOException {
		/*
		test("D.in");
		 */
		try {
			init(true, "D");
		} catch (Exception e) {
			init(false, "");
		}
		boolean multy = false;

		if (!multy) {
			while (in.ready() || st.hasMoreTokens()) {
				do_solve();
			}
		} else {
			for (int T = _int(); T > 0; --T) {
				do_solve();
			}
		}
		out.close();
	}

	void init(boolean FILE, String name) throws NumberFormatException,
			IOException {
		Locale.setDefault(Locale.US);
		if (FILE) {
			in = new BufferedReader(new FileReader(name + ".in"));
			out = new PrintWriter(name + ".out");
		} else {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}
		st = new StringTokenizer("");
	}

	void test(String name) throws IOException {
		out = new PrintWriter(new File(name));

		out.close();
	}

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		long T = System.currentTimeMillis();
		new D().mainProgram();
		System.err.println("Time of working: "
				+ (System.currentTimeMillis() - T) + " ms");
	}

	String _token() throws IOException {
		while (in.ready() && !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		if (st.hasMoreTokens())
			return st.nextToken();
		return "";
	}

	BigInteger add(BigInteger A, BigInteger B) {
		return A.add(B);
	}

	BigInteger mult(BigInteger A, BigInteger B) {
		return A.multiply(B);
	}

	BigInteger sub(BigInteger A, BigInteger B) {
		return A.subtract(B);
	}

	BigInteger div(BigInteger A, BigInteger B) {
		return A.divide(B);
	}

	BigInteger mi(BigInteger A) {
		return (BigInteger.ZERO).subtract(A);
	}

	BigInteger sq(BigInteger A) {
		return A.multiply(A);
	}

	BigInteger val(long a) {
		return BigInteger.valueOf(a);
	}

	int cmp(BigInteger a, BigInteger b) {
		return a.compareTo(b);
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	int _int() throws NumberFormatException, IOException {
		return Integer.parseInt(_token());
	}

	long _long() throws NumberFormatException, IOException {
		return Long.parseLong(_token());
	}

	double _double() throws NumberFormatException, IOException {
		return Double.parseDouble(_token());
	}

	int gcd(int a, int b) {
		if (a < 0)
			a = -a;
		if (b < 0)
			b = -b;
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	long gcd(long a, long b) {
		if (a < 0)
			a = -a;
		if (b < 0)
			b = -b;
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	BigInteger gcd(BigInteger a, BigInteger b) {
		if (cmp(a, val(0)) < 0)
			a = mi(a);
		if (cmp(b, val(0)) < 0)
			b = mi(b);
		return a.gcd(b);
	}
}
