#include <bits/stdc++.h>
using namespace std;
const int MAXN = 510;
const int di[4]{-1, 0, 1, 0};
const int dj[4]{0, 1, 0, -1};
const int inf = 1e9;
int N, K;
char a[MAXN][MAXN];
int label[MAXN][MAXN];
int lsize[MAXN * MAXN];
int sum[MAXN][MAXN], in[MAXN][MAXN];
int seen[MAXN * MAXN];
int count(int i, int j) {
  return sum[i + K - 1][j + K - 1] - sum[i - 1][j + K - 1] -
         sum[i + K - 1][j - 1] + sum[i - 1][j - 1];
}
void dfs(int i, int j, int &mini, int &maxi, int &minj, int &maxj,
         int &clabel) {
  lsize[clabel]++;
  label[i][j] = clabel;
  mini = min(mini, i);
  minj = min(minj, j);
  maxi = max(maxi, i);
  maxj = max(maxj, j);
  for (int d = 0; d < 4; d++) {
    int ni = i + di[d], nj = j + dj[d];
    if (ni < 1 || nj < 1 || ni > N || nj > N || a[ni][nj] != '.' ||
        label[ni][nj])
      continue;
    dfs(ni, nj, mini, maxi, minj, maxj, clabel);
  }
}
void add(int &count, int x, int del = 0) {
  if (del) {
    seen[x] = 0;
    return;
  }
  if (seen[x]) return;
  seen[x] = 1;
  count += lsize[x];
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%s", &a[i][1]);
    for (int j = 1; j <= N; j++)
      sum[i][j] =
          sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (a[i][j] == '.');
  }
  int clabel = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (label[i][j] || a[i][j] != '.') continue;
      int mini = inf, maxi = -inf, minj = inf, maxj = -inf;
      dfs(i, j, mini, maxi, minj, maxj, clabel);
      clabel++;
      if (maxi - mini + 1 <= K && maxj - minj + 1 <= K) {
        int i1 = max(maxi - K + 1, 0), i2 = mini;
        int j1 = max(maxj - K + 1, 0), j2 = minj;
        int x = lsize[clabel - 1];
        in[i1][j1] += x;
        in[i2 + 1][j1] -= x;
        in[i1][j2 + 1] -= x;
        in[i2 + 1][j2 + 1] += x;
      }
    }
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      if (i) in[i][j] += in[i - 1][j];
      if (j) in[i][j] += in[i][j - 1];
      if (i && j) in[i][j] -= in[i - 1][j - 1];
    }
  }
  int ans = 0;
  for (int i = 1; i + K - 1 <= N; i++) {
    for (int j = 1; j + K - 1 <= N; j++) {
      int csize = 0;
      for (int k = 1; k <= K; k++) {
        add(csize, label[i - 1 + k][j - 1]);
        add(csize, label[i + K][j - 1 + k]);
        add(csize, label[i + K - k][j + K]);
        add(csize, label[i - 1][j + K - k]);
      }
      int cur = csize + K * K - count(i, j) + in[i][j];
      ans = max(ans, cur);
      for (int k = 1; k <= K; k++) {
        add(csize, label[i - 1 + k][j - 1], 1);
        add(csize, label[i + K][j - 1 + k], 1);
        add(csize, label[i + K - k][j + K], 1);
        add(csize, label[i - 1][j + K - k], 1);
      }
    }
  }
  printf("%d\n", ans);
}
