import java.io.*;
import java.util.*;

public class complexity_pk {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	final long modulo = Integer.MAX_VALUE;

	public void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();
		assert((1 <= n) && (n <= 500));
		assert((1 <= k) && (k <= n));
		
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			for (int j = 0; j < n; j++) {
				assert(s.charAt(j) == 'w' || (s.charAt(j) == 'b'));
				if (s.charAt(j) == 'w')
					a[i][j] = 1;
				else
					a[i][j] = 0;
			}
		}
		long[] pow = new long[n * n + 1];
		pow[0] = 1;
		for (int i = 1; i < n * n + 1; i++)
			pow[i] = pow[i - 1] * 3;
		long full = 0;
		for (int i = 0; i < k; i++) {
			full *= 3;
			full += 1;
		}
		ArrayList<Long> res = new ArrayList<Long>();
		for (int i = 0; i < n - k + 1; i++) {
			int[] cColumn = new int[n];
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					cColumn[j] = 1;
			}
			long[][] hash = new long[k - 1][n - k + 1];
			for (int t = 1 + i; t < k + i; t++) {
				long tHash = 0;
				for (int j = 0; j < k; j++) {
					tHash *= 3;
					tHash += cColumn[j] ^ a[t][j];
				}
				for (int j = 0; j < n - k + 1; j++) {
					if ((cColumn[j] ^ a[t][j]) == 0) {
						hash[t - i - 1][j] = tHash;
					} else {
						hash[t - i - 1][j] = full - tHash;
						tHash -= pow[k - 1];
					}
					tHash *= 3;
					if (j + k < n)
						tHash += cColumn[j + k] ^ a[t][j + k];
						
				}
			}
			for (int j = 0; j < n - k + 1; j++) {
				long globalHash = 0;
				for (int t = 0; t < k - 1; t++) {
					globalHash *= pow[n];
					globalHash += hash[t][j];
				}
				res.add(globalHash);
			}
		}
		Collections.sort(res);
		int  p = 0;
		long ans = 0;
		for (int i = 1; i < (n - k + 1) * (n - k + 1); i++) {
			p++;
			if (!res.get(i).equals(res.get(i - 1))) {
				//out.println(p);
				p = 0;
			}
			ans += i - p;
		}
		//out.println(p + 1);
		out.println(ans);
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("complexity.in"));
			out = new PrintWriter("complexity.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new complexity_pk().run();
	}
}