#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
char sv[MAXN][MAXN] = {'\0'};
int dis[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int book[MAXN][MAXN] = {0}, cnt[MAXN * MAXN] = {0};
bool vis[MAXN * MAXN];
int n, k;
bool judge(int x, int y) {
  if (x < 1 || x > n) {
    return false;
  }
  if (y < 1 || y > n) {
    return false;
  }
  if (book[x][y]) {
    return false;
  }
  if (sv[x][y] != '.') {
    return false;
  }
  return true;
}
void dfs(int x, int y, int no) {
  int tx, ty;
  book[x][y] = no;
  cnt[no]++;
  for (int i = 0; i < 4; i++) {
    tx = x + dis[i][0];
    ty = y + dis[i][1];
    if (judge(tx, ty)) {
      dfs(tx, ty, no);
    }
  }
}
void up1(int x, int y, int t) {
  for (int i = x; i <= x + k - 1; i++) {
    for (int j = y; j <= y + k - 1; j++) {
      if (book[i][j]) {
        cnt[book[i][j]] += t;
      }
    }
  }
}
void up2(int x, int y, int t) {
  for (int i = x; i <= x + k - 1; i++) {
    if (book[i][y]) {
      cnt[book[i][y]] += t;
    }
  }
}
stack<int> st;
int cal(int x, int y) {
  int ret = 0;
  for (int j = y; j <= y + k - 1; j++) {
    if (book[x - 1][j] && !vis[book[x - 1][j]]) {
      st.push(book[x - 1][j]);
      vis[book[x - 1][j]] = true;
      ret += cnt[book[x - 1][j]];
    }
  }
  for (int j = y; j <= y + k - 1; j++) {
    if (book[x + k][j] && !vis[book[x + k][j]]) {
      st.push(book[x + k][j]);
      vis[book[x + k][j]] = true;
      ret += cnt[book[x + k][j]];
    }
  }
  for (int i = x; i <= x + k - 1; i++) {
    if (book[i][y - 1] && !vis[book[i][y - 1]]) {
      st.push(book[i][y - 1]);
      vis[book[i][y - 1]] = true;
      ret += cnt[book[i][y - 1]];
    }
  }
  for (int i = x; i <= x + k - 1; i++) {
    if (book[i][y + k] && !vis[book[i][y + k]]) {
      st.push(book[i][y + k]);
      vis[book[i][y + k]] = true;
      ret += cnt[book[i][y + k]];
    }
  }
  while (!st.empty()) {
    int t = st.top();
    st.pop();
    vis[t] = false;
  }
  return ret;
}
int main() {
  int tot = 1;
  memset(vis, false, sizeof(vis));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", sv[i] + 1);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (sv[i][j] == '.' && !book[i][j]) {
        dfs(i, j, tot++);
      }
    }
  }
  int res = 0;
  for (int i = 1; i + k - 1 <= n; i++) {
    up1(i, 1, -1);
    res = max(res, cal(i, 1));
    for (int j = 2; j + k - 1 <= n; j++) {
      up2(i, j - 1, 1);
      up2(i, j + k - 1, -1);
      res = max(res, cal(i, j));
    }
    up1(i, n - k + 1, 1);
  }
  cout << res + k * k << endl;
}
