#include <bits/stdc++.h>
using namespace std;
long long n, k, ans, all, cnt, tmp;
char a[505][505];
long long f[505][505], colour[250050], sum[505][505], vi[250050];
void dfs(long long x, long long y) {
  tmp++;
  f[x][y] = cnt;
  if (a[x - 1][y] == '.' && !f[x - 1][y]) dfs(x - 1, y);
  if (a[x + 1][y] == '.' && !f[x + 1][y]) dfs(x + 1, y);
  if (a[x][y - 1] == '.' && !f[x][y - 1]) dfs(x, y - 1);
  if (a[x][y + 1] == '.' && !f[x][y + 1]) dfs(x, y + 1);
}
inline void Delete(long long x, long long y) {
  if (!f[x][y]) return;
  long long t = f[x][y];
  --vi[t];
  if (!vi[t]) all -= colour[t];
}
inline void insert(long long x, long long y) {
  if (!f[x][y]) return;
  long long t = f[x][y];
  if (!vi[t]) all += colour[t];
  vi[t]++;
}
inline long long calc(long long x, long long y) {
  return sum[x + k - 1][y + k - 1] - sum[x + k - 1][y - 1] -
         sum[x - 1][y + k - 1] + sum[x - 1][y - 1];
}
int main() {
  long long i, j;
  cin >> n >> k;
  for (i = 1; i <= n; ++i) {
    scanf("%s", a[i] + 1);
    for (j = 1; j <= n; ++j) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
      if (a[i][j] == '.') sum[i][j]++;
    }
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      if (a[i][j] == '.' && !f[i][j]) {
        cnt++;
        tmp = 0;
        dfs(i, j);
        colour[cnt] = tmp;
      }
    }
  }
  for (i = 1; i <= n - k + 1; ++i) {
    all = 0;
    memset(vi, 0, sizeof(vi));
    for (j = i - 1; j <= k + i; ++j) {
      for (long long l = 1; l <= k; ++l) insert(j, l);
    }
    for (j = i; j < i + k; ++j) insert(j, k + 1);
    ans = max(ans, all + k * k - calc(i, 1));
    for (j = 2; j <= n - k + 1; ++j) {
      for (long long l = i; l < i + k; ++l) {
        Delete(l, j - 2);
        insert(l, j + k);
      }
      Delete(i - 1, j - 1);
      Delete(i + k, j - 1);
      insert(i - 1, j + k - 1);
      insert(i + k, j + k - 1);
      ans = max(ans, all + k * k - calc(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}
