#include <bits/stdc++.h>
using namespace std;
const int N = 511;
int n, k;
char mp[N][N];
int vis[N][N];
int val[N * N];
int t[N * N];
int sum[N][N];
int xi[] = {0, 1, 0, -1};
int yi[] = {1, 0, -1, 0};
int temp;
struct node {
  int x, y;
  node() {}
  node(int x, int y) : x(x), y(y) {}
};
void bfs(int cnt, int x, int y) {
  queue<node> q;
  vis[x][y] = cnt;
  q.push(node(x, y));
  while (q.size()) {
    node e = q.front();
    q.pop();
    val[cnt]++;
    for (int i = 0; i < 4; i++) {
      int xx = e.x + xi[i], yy = e.y + yi[i];
      if (xx > 0 && xx <= n && yy > 0 && yy <= n && !vis[xx][yy] &&
          mp[xx][yy] == '.') {
        vis[xx][yy] = cnt;
        q.push(node(xx, yy));
      }
    }
  }
}
void del(int i, int j) {
  if (!vis[i][j]) return;
  if ((--t[vis[i][j]]) == 0) temp -= val[vis[i][j]];
}
void add(int i, int j) {
  if (!vis[i][j]) return;
  if ((++t[vis[i][j]]) == 1) temp += val[vis[i][j]];
}
int cal(int x, int y) {
  return sum[x][y] - sum[x - k][y] - sum[x][y - k] + sum[x - k][y - k];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (mp[i][j] == '.') sum[i][j] = 1;
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (!vis[i][j] && mp[i][j] == '.') {
        bfs(++cnt, i, j);
      }
    }
  }
  int ret = 0;
  for (int i = 1; i <= n - k + 1; ++i) {
    temp = 0, memset(t, 0, sizeof(t));
    for (int p = i - 1; p <= i + k; ++p)
      for (int q = 1; q <= k + 1; ++q) add(p, q);
    del(i - 1, k + 1), del(i + k, k + 1);
    ret = max(ret, temp + k * k - cal(i + k - 1, k));
    for (int p = 2; p <= n - k + 1; ++p) {
      for (int q = i; q <= i + k - 1; ++q) del(q, p - 2), add(q, p + k);
      del(i - 1, p - 1);
      del(i + k, p - 1);
      add(i - 1, p + k - 1);
      add(i + k, p + k - 1);
      ret = max(ret, temp + k * k - cal(i + k - 1, p + k - 1));
    }
  }
  printf("%d\n", ret);
  return 0;
}
