#include <bits/stdc++.h>
using namespace std;
const int N = 502;
int n, k;
string s[N];
int hx[4] = {-1, 0, 1, 0};
int hy[4] = {0, 1, 0, -1};
int m;
int a[N][N], d[N][N], cc[N * N];
bool ccc[N * N];
int ans = 0;
int sum;
void enter() {
  cin >> n >> k;
  for (int i = 0; i <= n; i++) getline(cin, s[i]);
  memset(a, 255, sizeof(a));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (s[i][j - 1] == '.') a[i][j] = 0;
}
void visit(int x, int y) {
  a[x][y] = m;
  cc[m]++;
  for (int j = 0; j <= 3; j++)
    if (a[x + hx[j]][y + hy[j]] == 0) visit(x + hx[j], y + hy[j]);
}
int get(int x, int y, int u, int v) {
  return d[u][v] - d[u][y - 1] - d[x - 1][v] + d[x - 1][y - 1];
}
void pushcc(int typ, int p, int i, int j) {
  if (typ == 1) {
    for (int q = i; q <= j; q++)
      if (a[p][q] != -1 && ccc[a[p][q]] == 0) {
        ccc[a[p][q]] = 1;
        sum += cc[a[p][q]];
      }
  } else {
    for (int q = i; q <= j; q++)
      if (a[q][p] != -1 && ccc[a[q][p]] == 0) {
        ccc[a[q][p]] = 1;
        sum += cc[a[q][p]];
      }
  }
}
void popcc(int typ, int p, int i, int j) {
  if (p <= 0) return;
  if (typ == 1) {
    for (int q = i; q <= j; q++)
      if (a[p][q] != -1 && ccc[a[p][q]] == 1) {
        ccc[a[p][q]] = 0;
        sum -= cc[a[p][q]];
      }
  } else {
    for (int q = i; q <= j; q++)
      if (a[q][p] != -1 && ccc[a[q][p]] == 1) {
        ccc[a[q][p]] = 0;
        sum -= cc[a[q][p]];
      }
  }
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] - a[i][j];
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++)
      if (a[x][y] == 0) {
        m++;
        visit(x, y);
        ans = max(ans, cc[m]);
      }
  if (k > 1)
    for (int i = 1; i <= n - k + 1; i++) {
      sum = get(i, 1, i + k - 1, k);
      for (int j = 1; j <= k; j++) pushcc(2, j, i, i + k - 1);
      pushcc(2, k + 1, i, i + k - 1);
      pushcc(1, i - 1, 1, k);
      pushcc(1, i + k, 1, k);
      ans = max(ans, sum);
      for (int j = 2; j <= n - k + 1; j++) {
        sum += get(i, j, i + k - 1, j + k - 1) -
               get(i, j - 1, i + k - 1, j + k - 2);
        popcc(2, j - 2, i, i + k - 1);
        popcc(2, j - 1, i, i + k - 1);
        popcc(2, j - 1, i - 1, i - 1);
        popcc(2, j - 1, i + k, i + k);
        pushcc(2, j + k - 1, i, i + k - 1);
        pushcc(1, i, j, j + k - 2);
        pushcc(1, i + k - 1, j, j + k - 2);
        pushcc(1, i - 1, j, j + k - 1);
        pushcc(1, i + k, j, j + k - 1);
        pushcc(2, j + k, i, i + k - 1);
        pushcc(2, j - 1, i, i + k - 1);
        ans = max(ans, sum);
      }
      for (int j = 1; j <= m; j++) ccc[j] = 0;
    }
  else {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (a[i][j] == -1) {
          sum = 0;
          for (int l = 0; l <= 3; l++) {
            int lx = i + hx[l];
            int ly = j + hy[l];
            if (lx > 0 && ly > 0 && lx <= n && ly <= n && a[lx][ly] > 0)
              ccc[a[lx][ly]] = 1;
          }
          for (int l = 0; l <= 3; l++) {
            int lx = i + hx[l];
            int ly = j + hy[l];
            if (lx > 0 && ly > 0 && lx <= n && ly <= n && a[lx][ly] > 0 &&
                ccc[a[lx][ly]] == 1) {
              ccc[a[lx][ly]] = 0;
              sum += cc[a[lx][ly]];
            }
          }
          ans = max(ans, sum + 1);
        }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  enter();
  solve();
  return 0;
}
