#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int n, k;
vector< vector<char> > a;
#define matrix vector< vector<char> >

matrix normileze(int x, int y)
{
	vector<char> row(k, 0), col(k, 0);
	if (a[x][y] == 1)
		row[0] = 1;
	for (int i = 1; i < k; i++)
		if ((a[x][y + i] ^ row[0]) == 1) col[i] = 1;
	for (int i = 1; i < k; i++)
		if (a[x + i][y] == 1) row[i] = 1;
	
	matrix b(k, vector<char>(k));
	for (int i = 0; i < k; i++)
		for (int j = 0; j < k; j++)
			b[i][j] = a[x + i][y + j] ^ col[j] ^ row[i];

	return b;
}

bool comp(matrix a, matrix b)
{
	for (int i = 0; i < k; i++)
		for (int j = 0; j < k; j++)
			if (a[i][j] != b[i][j]) 
				return a[i][j] > b[i][j];
	return false;
}

int main()
{
	freopen("complexity.in", "r", stdin);
	freopen("complexity.out", "w", stdout);
	scanf("%d%d\n", &n, &k);
	a =  vector< vector<char> > (n, vector<char>(n));
	for (int i = 0; i < n; i++)
	{
		char x;
		for (int j = 0; j < n; j++)
		{
			scanf("%c", &x);
			a[i][j] = (x == 'b') ? 1 : 0;
		}
		scanf("\n");
	}
	
	vector< matrix > matr;
	for (int x = 0;  x <= n - k; x++)
		for (int y = 0; y <= n - k; y++)
			matr.push_back(normileze(x, y));
	
	vector<int> cnt;
	sort(matr.begin(), matr.end(), comp);
	int uk1 = 0;
	for (size_t i = 1; i < matr.size(); i++)
	{
		if (comp(matr[i], matr[uk1]) || comp(matr[uk1], matr[i])) 
		{
			cnt.push_back(i - uk1);
			uk1 = i;
		}
	}
	cnt.push_back(matr.size() - uk1);
	int count = (n - k + 1)*(n - k + 1);
	long long ans = 0;
	for (size_t i = 0; i < cnt.size(); i++)
	{
		count -= cnt[i];
		ans += cnt[i] * count;
	}
	cout << ans;
}  