#include <bits/stdc++.h>
using namespace std;
const int maxn = 502;
char A[maxn][maxn];
int n, k;
int cc_size[maxn * maxn];
int cc[maxn][maxn];
int ans = 0, answer = 0;
bool Free[maxn][maxn];
bool dd[maxn * maxn];
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
bool Inside(int x, int y) { return (1 <= x && x <= n && 1 <= y && y <= n); }
void Solve(int x1, int y1, int x2, int y2) {
  memset(dd, 0, sizeof dd);
  for (int i = y1; i <= y2; ++i)
    if (!dd[cc[x1 - 1][i]] && Inside(x1 - 1, i) && A[x1 - 1][i] == '.') {
      ans += cc_size[cc[x1 - 1][i]];
      dd[cc[x1 - 1][i]] = 1;
    }
  for (int i = y1; i <= y2; ++i)
    if (!dd[cc[x2 + 1][i]] && Inside(x2 + 1, i) && A[x2 + 1][i] == '.') {
      ans += cc_size[cc[x2 + 1][i]];
      dd[cc[x2 + 1][i]] = 1;
    }
  for (int i = x1; i <= x2; ++i) {
    if (!dd[cc[i][y2 + 1]] && Inside(i, y2 + 1) && A[i][y2 + 1] == '.') {
      ans += cc_size[cc[i][y2 + 1]];
      dd[cc[i][y2 + 1]] = 1;
    }
  }
  for (int i = x1; i <= x2; ++i)
    if (!dd[cc[i][y1 - 1]] && Inside(i, y1 - 1) && A[i][y1 - 1] == '.') {
      ans += cc_size[cc[i][y1 - 1]];
      dd[cc[i][y1 - 1]] = 1;
    }
}
void DFS(int i, int j, int id) {
  Free[i][j] = 0;
  cc[i][j] = id;
  cc_size[id]++;
  for (int k = 0; k <= 3; ++k) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (Inside(x, y) && A[x][y] == '.' && Free[x][y]) DFS(x, y, id);
  }
}
int main() {
  scanf("%d%d\n", &n, &k);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      char c = getchar();
      A[i][j] = c;
      Free[i][j] = (c == '.');
    }
    scanf("\n");
  }
  int id = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (Free[i][j]) DFS(i, j, ++id);
  for (int y = 1; y <= n - k + 1; ++y) {
    for (int i = 1; i <= k; ++i)
      for (int j = y; j <= y + k - 1; ++j) cc_size[cc[i][j]]--;
    for (int i = 1; i <= n - k + 1; ++i) {
      ans = k * k;
      Solve(i, y, i + k - 1, y + k - 1);
      answer = max(ans, answer);
      if (i + k <= n) {
        for (int h = y; h <= y + k - 1; ++h) {
          cc_size[cc[i][h]]++;
          cc_size[cc[i + k][h]]--;
        }
      }
    }
    for (int i = n - k + 1; i <= n; ++i)
      for (int j = y; j <= y + k - 1; ++j) cc_size[cc[i][j]]++;
  }
  printf("%d", answer);
}
