#include <bits/stdc++.h>
using namespace std;
const int maxN = 505;
int n, k;
int a[maxN][maxN];
char gchar() {
  char r = getchar();
  while (r == ' ' || r == '\n' || r == '\r') r = getchar();
  return r;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool inA(int x, int y) {
  if (x < 1 || y < 1 || x > n || y > n) return false;
  return true;
}
int flg;
void dfs(int x, int y) {
  a[x][y] = flg;
  for (int i = 0; i < 4; ++i) {
    int tx = x + dx[i];
    int ty = y + dy[i];
    if (inA(tx, ty) && a[tx][ty] == 0) {
      dfs(tx, ty);
    }
  }
}
int g[maxN][maxN];
int sz[maxN * maxN];
int rec[maxN * maxN];
int tg[maxN * maxN];
int get(int x, int y) {
  return g[x + k - 1][y + k - 1] - g[x - 1][y] - g[x][y - 1] + g[x - 1][y - 1];
}
int main() {
  scanf("%d%d", &n, &k);
  memset(a, -1, sizeof a);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (gchar() == '.') a[i][j] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (a[i][j] == 0) {
        ++flg;
        dfs(i, j);
      }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) ++sz[a[i][j]];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      g[i][j] = g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + (a[i][j] == -1);
  memcpy(rec, sz, sizeof sz);
  int ans = 0;
  flg = 0;
  for (int i = 1; i <= n - k + 1; ++i) {
    memcpy(sz, rec, sizeof rec);
    for (int x = 0; x < k; ++x)
      for (int j = 1; j <= k; ++j) --sz[a[i + x][j]];
    for (int j = 1; j <= n - k + 1; ++j) {
      ++flg;
      int sum = k * k;
      for (int p = 0; p < k; ++p) {
        if (a[i - 1][j + p] != -1) {
          if (tg[a[i - 1][j + p]] != flg) {
            sum += sz[a[i - 1][j + p]];
            tg[a[i - 1][j + p]] = flg;
          }
        }
        if (a[i + k][j + p] != -1) {
          if (tg[a[i + k][j + p]] != flg) {
            sum += sz[a[i + k][j + p]];
            tg[a[i + k][j + p]] = flg;
          }
        }
        if (a[i + p][j - 1] != -1) {
          if (tg[a[i + p][j - 1]] != flg) {
            sum += sz[a[i + p][j - 1]];
            tg[a[i + p][j - 1]] = flg;
          }
        }
        if (a[i + p][j + k] != -1) {
          if (tg[a[i + p][j + k]] != flg) {
            sum += sz[a[i + p][j + k]];
            tg[a[i + p][j + k]] = flg;
          }
        }
      }
      ans = max(ans, sum);
      for (int p = 0; p < k; ++p) {
        if (a[i + p][j] != -1) ++sz[a[i + p][j]];
        if (a[i + p][j + k] != -1) --sz[a[i + p][j + k]];
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
