#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int g[1010][1010];
int numb[1010][1010];
int num[1010 * 1010];
int cnt = 0, n;
int mini, minj;
int maxi, maxj;
int way[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};
int vis[1010 * 1010];
void dfs(int x, int y) {
  g[x][y] = cnt;
  num[cnt]++;
  mini = min(mini, x);
  minj = min(minj, y);
  maxi = max(maxi, x);
  maxj = max(maxj, y);
  for (int i = 0; i < 4; i++) {
    int a = x + way[i][0];
    int b = y + way[i][1];
    if (a < 1 || b < 1 || a > n || b > n || g[a][b] != -1) continue;
    dfs(a, b);
  }
}
int main() {
  int k;
  char s[510];
  scanf("%d%d", &n, &k);
  getchar();
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 1; j <= n; j++) {
      if (s[j - 1] == '.')
        g[i][j] = -1;
      else {
        g[i][j] = 0;
        numb[i][j] += 1;
        numb[i + k][j] -= 1;
        numb[i][j + k] -= 1;
        numb[i + k][j + k] += 1;
      }
    }
  }
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (g[i][j] == -1) {
        cnt++;
        mini = i, minj = j, maxi = i, maxj = j;
        dfs(i, j);
        if (maxi - mini + 1 <= k && maxj - minj + 1 <= k) {
          numb[maxi][maxj] += num[cnt];
          numb[maxi][minj + k] -= num[cnt];
          numb[mini + k][maxj] -= num[cnt];
          numb[mini + k][minj + k] += num[cnt];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      numb[i][j] += numb[i - 1][j] + numb[i][j - 1] - numb[i - 1][j - 1];
    }
  }
  int ans = 0;
  int xi, xj;
  for (int i = k; i <= n; i++) {
    for (int j = k; j <= n; j++) {
      int re = 0;
      for (int p = j - k + 1; p <= j; p++) {
        if (!vis[g[i - k][p]]) vis[g[i - k][p]] = 1, re += num[g[i - k][p]];
        if (!vis[g[i + 1][p]]) vis[g[i + 1][p]] = 1, re += num[g[i + 1][p]];
      }
      for (int p = i - k + 1; p <= i; p++) {
        if (!vis[g[p][j - k]]) vis[g[p][j - k]] = 1, re += num[g[p][j - k]];
        if (!vis[g[p][j + 1]]) vis[g[p][j + 1]] = 1, re += num[g[p][j + 1]];
      }
      ans = max(ans, re + numb[i][j]);
      for (int p = j - k + 1; p <= j; p++)
        vis[g[i - k][p]] = 0, vis[g[i + 1][p]] = 0;
      for (int p = i - k + 1; p <= i; p++)
        vis[g[p][j - k]] = 0, vis[g[p][j + 1]] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
