#include <bits/stdc++.h>
using namespace std;
long long n, k, a[555][555], D[250250], area = 0, cur = 0, A[250250],
                                        S[555][555], N;
long long dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}, mom[555][555];
void over(int i, int j) {
  if (i < 1 || j < 1 || i > n || j > n) return;
  if (a[i][j] == 0 || mom[i][j] != 0) return;
  mom[i][j] = N;
  for (int k = 0; k < 4; ++k) {
    over(i + dx[k], j + dy[k]);
  }
}
void add(int i, int j) {
  if (i < 1 || j < 1 || i > n || j > n) return;
  if (a[i][j] == 1) {
    ++D[mom[i][j]];
    if (D[mom[i][j]] == 1) {
      cur += A[mom[i][j]];
    }
  }
}
void del(int i, int j) {
  if (i < 1 || j < 1 || i > n || j > n) return;
  if (a[i][j] == 1) {
    --D[mom[i][j]];
    if (D[mom[i][j]] == 0) {
      cur -= A[mom[i][j]];
    }
  }
}
int main() {
  cin >> n >> k;
  getchar();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      a[i][j] = getchar() == '.';
      S[i][j] = (1 - a[i][j]) + S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1];
    }
    getchar();
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (a[i][j] == 1 && mom[i][j] == 0) {
        ++N;
        over(i, j);
      }
      if (mom[i][j] > 0) {
        ++A[mom[i][j]];
      }
    }
  }
  for (int h = k; h <= n + 1; ++h) {
    cur = 0;
    memset(D, 0, sizeof D);
    for (int j = 1; j <= k; ++j) {
      for (int i = h; h - i + 1 <= k + 2; --i) {
        add(i, j);
      }
    }
    for (int j = k + 1; j <= n + 1; ++j) {
      for (int i = h; h - i + 1 <= k + 2; --i) {
        add(i, j);
        del(i, j - (k + 2));
      }
      del(h, j);
      del(h - (k + 1), j);
      del(h, j - (k + 1));
      del(h - (k + 1), j - (k + 1));
      if (cur + (S[h - 1][j - 1] - S[h - 1][j - (k + 1)] -
                 S[h - (k + 1)][j - 1] + S[h - (k + 1)][j - (k + 1)]) >
          area) {
        area = cur + (S[h - 1][j - 1] - S[h - 1][j - (k + 1)] -
                      S[h - (k + 1)][j - 1] + S[h - (k + 1)][j - (k + 1)]);
      }
      add(h, j);
      add(h - (k + 1), j);
      add(h, j - (k + 1));
      add(h - (k + 1), j - (k + 1));
    }
  }
  cout << area << "\n";
}
