#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 10;
char s[maxn];
int mp[maxn][maxn], ans, id[maxn][maxn], pa[maxn * maxn], n, k, sz[maxn * maxn];
int is[maxn * maxn], s1, s2;
int find(int p) {
  if (pa[p] == p)
    return p;
  else
    return pa[p] = find(pa[p]);
}
void merge(int x, int y) {
  int fa = find(x), fb = find(y);
  if (fa != fb) {
    pa[fa] = fb;
    sz[fb] += sz[fa];
  }
}
void add(int x, int y, int f) {
  if (mp[x][y]) {
    int fa = find(id[x][y]);
    if (!is[fa]) s1 += sz[fa];
    is[fa]++;
  } else if (f == 1)
    s2++;
}
void rev(int x, int y, int f) {
  if (mp[x][y]) {
    int fa = find(id[x][y]);
    if (is[fa] == 1) s1 -= sz[fa];
    is[fa]--;
  } else if (f == 1)
    s2--;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      id[i][j] = (i - 1) * n + j;
      pa[id[i][j]] = id[i][j];
      sz[id[i][j]] = 1;
    }
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++)
      if (s[j] == '.')
        mp[i][j] = 1;
      else
        mp[i][j] = 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (mp[i][j]) {
        if (j < n && mp[i][j + 1]) merge(id[i][j], id[i][j + 1]);
        if (i < n && mp[i + 1][j]) merge(id[i][j], id[i + 1][j]);
      }
  for (int i = 1; i <= n - k + 1; i++)
    for (int j = 1; j <= n - k + 1; j++) {
      if (j == 1) {
        for (int r = i; r <= i + k - 1; r++)
          for (int c = j; c <= j + k - 1; c++) add(r, c, 1);
      } else
        for (int r = i; r <= i + k - 1; r++) add(r, j + k - 1, 1);
      if (j + k <= n)
        for (int r = i; r <= i + k - 1; r++) add(r, j + k, 0);
      if (j > 1)
        for (int r = i; r <= i + k - 1; r++) add(r, j - 1, 0);
      if (i > 1)
        for (int c = j; c <= j + k - 1; c++) add(i - 1, c, 0);
      if (i + k <= n)
        for (int c = j; c <= j + k - 1; c++) add(i + k, c, 0);
      ans = max(ans, s1 + s2);
      if (j != n - k + 1)
        for (int r = i; r <= i + k - 1; r++) rev(r, j, 1);
      else {
        for (int r = i; r <= i + k - 1; r++)
          for (int c = j; c <= j + k - 1; c++) rev(r, c, 1);
      }
      if (j + k <= n)
        for (int r = i; r <= i + k - 1; r++) rev(r, j + k, 0);
      if (j > 1)
        for (int r = i; r <= i + k - 1; r++) rev(r, j - 1, 0);
      if (i > 1)
        for (int c = j; c <= j + k - 1; c++) rev(i - 1, c, 0);
      if (i + k <= n)
        for (int c = j; c <= j + k - 1; c++) rev(i + k, c, 0);
    }
  cout << ans << endl;
  return 0;
}
