#include <bits/stdc++.h>
using namespace std;
const int maxn = 520, maxm = maxn * maxn;
struct node {
  int x, y;
} Y[maxm], M[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
char s[maxn];
int f[maxm], g[maxm], vis[maxm];
int a[maxn][maxn], X[maxn][maxn];
int i, j, n, m, K, ans, bla, now, tot;
bool out(int x, int y) { return x < 1 || y < 1 || x > n || y > n; }
int find(int o) {
  if (o == f[o]) return o;
  return f[o] = find(f[o]);
}
void prepare(int x, int y) {
  int i, j;
  for (i = x; i < x + K; i++)
    for (j = y; j < y + K; j++) {
      bla += a[i][j];
      if (a[i][j]) continue;
      int u = f[X[i][j]];
      vis[u]++;
      if (vis[u] == 1) now += g[u];
    }
  for (j = y; j < y + K; j++) {
    if (!out(x - 1, j) && !a[x - 1][j]) {
      int u = f[X[x - 1][j]];
      vis[u]++;
      if (vis[u] == 1) now += g[u];
    }
    if (!out(x + K, j) && !a[x + K][j]) {
      int u = f[X[x + K][j]];
      vis[u]++;
      if (vis[u] == 1) now += g[u];
    }
  }
  for (i = x; i < x + K; i++) {
    if (!out(i, y - 1) && !a[i][y - 1]) {
      int u = f[X[i][y - 1]];
      vis[u]++;
      if (vis[u] == 1) now += g[u];
    }
    if (!out(i, y + K) && !a[i][y + K]) {
      int u = f[X[i][y + K]];
      vis[u]++;
      if (vis[u] == 1) now += g[u];
    }
  }
}
int main() {
  scanf("%d%d", &n, &K);
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (j = 1; j <= n; j++) {
      if (s[j] == '.')
        a[i][j] = 0;
      else
        a[i][j] = 1;
      X[i][j] = ++tot;
      Y[tot] = (node){i, j};
      f[tot] = tot;
      g[tot] = 1;
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      if (a[i][j]) continue;
      int u = X[i][j];
      for (int k = 0; k < 4; k++) {
        int xx = i + M[k].x;
        int yy = j + M[k].y;
        if (out(xx, yy)) continue;
        if (a[xx][yy]) continue;
        int v = X[xx][yy];
        if (find(u) != find(v)) {
          g[f[v]] += g[f[u]];
          f[f[u]] = f[v];
        }
      }
    }
  for (i = 1; i <= tot; i++) find(i);
  for (i = 1; i + K - 1 <= n; i++) {
    memset(vis, 0, sizeof(vis));
    bla = now = 0;
    prepare(i, 1);
    ans = max(ans, bla + now);
    for (j = 2; j + K - 1 <= n; j++) {
      if (!out(i - 1, j - 1) && !a[i - 1][j - 1]) {
        int u = f[X[i - 1][j - 1]];
        vis[u]--;
        if (!vis[u]) now -= g[u];
      }
      if (!out(i + K, j - 1) && !a[i + K][j - 1]) {
        int u = f[X[i + K][j - 1]];
        vis[u]--;
        if (!vis[u]) now -= g[u];
      }
      if (!out(i - 1, j + K - 1) && !a[i - 1][j + K - 1]) {
        int u = f[X[i - 1][j + K - 1]];
        vis[u]++;
        if (vis[u] == 1) now += g[u];
      }
      if (!out(i + K, j + K - 1) && !a[i + K][j + K - 1]) {
        int u = f[X[i + K][j + K - 1]];
        vis[u]++;
        if (vis[u] == 1) now += g[u];
      }
      for (int k = i; k <= i + K - 1; k++) {
        if (a[k][j - 1]) bla--;
        if (!out(k, j - 2) && !a[k][j - 2]) {
          int u = f[X[k][j - 2]];
          vis[u]--;
          if (!vis[u]) now -= g[u];
        }
        if (a[k][j + K - 1]) bla++;
        if (!out(k, j + K) && !a[k][j + K]) {
          int u = f[X[k][j + K]];
          vis[u]++;
          if (vis[u] == 1) now += g[u];
        }
      }
      if (bla + now > ans) ans = bla + now;
    }
  }
  printf("%d", ans);
  return 0;
}
