#include <bits/stdc++.h>
using namespace std;
int a[510][510], v[510][510], n, k, f[510 * 510], siz[510 * 510],
    sum[510 * 510], b[510 * 510], ans;
int dx[4] = {0, 1, -1, 0};
int dy[4] = {1, 0, 0, -1};
char c[510][510];
int change(char _) { return (_ == '.') ? 0 : 1; }
int idx(int x, int y) { return (x - 1) * n + y; }
int find(int x) {
  if (f[x] != x) f[x] = find(f[x]);
  return f[x];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      a[i][j] = change(c[i][j]);
      f[idx(i, j)] = idx(i, j);
      siz[idx(i, j)] = 1;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (a[i][j]) continue;
      for (int d = 0; d < 4; d++) {
        int tx = i + dx[d], ty = j + dy[d];
        if (tx < 1 || tx > n || ty > n || ty < 1 || a[tx][ty]) continue;
        int t1 = idx(i, j), t2 = idx(tx, ty), f1 = find(t1), f2 = find(t2);
        if (f1 != f2) {
          f[f1] = f2;
          siz[f2] += siz[f1];
        }
      }
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) v[i][j] = find(idx(i, j));
  for (int i = 1; i <= n - k + 1; i++) {
    memset(sum, 0, sizeof(sum));
    for (int j = i; j <= i + k - 1; j++)
      for (int t = 1; t <= k; t++) sum[v[j][t]]++;
    for (int j = 1; j <= n - k + 1; j++) {
      int tot = 0;
      if (j != 1) {
        for (int t = i; t <= i + k - 1; t++)
          sum[v[t][j - 1]]--, sum[v[t][j + k - 1]]++;
      }
      for (int t = i; t <= i + k - 1; t++) {
        if (j > 1 && a[t][j - 1] == 0) {
          int t1 = v[t][j - 1];
          if (!b[t1]) {
            b[t1] = 1;
            tot += siz[t1] - sum[t1];
          }
        }
        if (j + k <= n && a[t][j + k] == 0) {
          int t1 = v[t][j + k];
          if (b[t1]) continue;
          b[t1] = 1;
          tot += siz[t1] - sum[t1];
        }
      }
      for (int t = j; t <= j + k - 1; t++) {
        if (i > 1 && a[i - 1][t] == 0) {
          int t1 = v[i - 1][t];
          if (!b[t1]) {
            b[t1] = 1;
            tot += siz[t1] - sum[t1];
          }
        }
        if (i + k <= n && a[i + k][t] == 0) {
          int t1 = v[i + k][t];
          if (b[t1]) continue;
          b[t1] = 1;
          tot += siz[t1] - sum[t1];
        }
      }
      for (int t = i; t <= i + k - 1; t++) {
        if (j > 1) {
          int t1 = v[t][j - 1];
          b[t1] = 0;
        }
        if (j + k <= n) {
          int t1 = v[t][j + k];
          b[t1] = 0;
        }
      }
      for (int t = j; t <= j + k - 1; t++) {
        if (i > 1) {
          int t1 = v[i - 1][t];
          b[t1] = 0;
        }
        if (i + k <= n) {
          int t1 = v[i + k][t];
          b[t1] = 0;
        }
      }
      ans = max(ans, tot + k * k);
    }
  }
  printf("%d\n", ans);
  return 0;
}
