#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  x = ch - '0';
  while (1) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    x = x * 10 + ch - '0';
  }
  return x * f;
}
const int maxn = 510;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int n, cc[maxn][maxn], size[maxn * maxn], toadd[maxn * maxn];
char c[maxn][maxn];
bool check(int x, int y) { return 0 <= min(x, y) && max(x, y) < n; }
void dfs(int x, int y, int num) {
  cc[x][y] = num;
  ++size[num];
  for (int i = 0; i < 4; i++) {
    int X = x + dx[i];
    int Y = y + dy[i];
    if (check(X, Y) && c[X][Y] == '.' && cc[X][Y] == 0) dfs(X, Y, num);
  }
}
void add(int x, int y, int &ans, int cnt) {
  if (check(x, y) && c[x][y] == '.') {
    int id = cc[x][y];
    if (toadd[id] != cnt) {
      toadd[id] = cnt;
      ans += size[id];
    }
  }
}
int main() {
  n = read();
  int k = read();
  for (int i = 0; i < n; i++) scanf("%s", c[i]);
  int counts = 0;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++)
      if (c[x][y] == '.' && cc[x][y] == 0) dfs(x, y, ++counts);
  int cnt = 1, best = 0;
  for (int rol = 0; rol + k <= n; rol++) {
    for (int x = 0; x < k; x++)
      for (int y = rol; y < rol + k; y++) --size[cc[x][y]];
    for (int line = 0; line + k <= n; line++) {
      int ans = k * k;
      for (int x = line; x < line + k; x++) {
        add(x, rol - 1, ans, cnt);
        add(x, rol + k, ans, cnt);
      }
      for (int y = rol; y < rol + k; y++) {
        add(line - 1, y, ans, cnt);
        add(line + k, y, ans, cnt);
      }
      cnt++;
      best = max(best, ans);
      if (line + k != n) {
        for (int y = rol; y < rol + k; y++)
          ++size[cc[line][y]], --size[cc[line + k][y]];
      }
    }
    for (int x = n - k; x < n; x++)
      for (int y = rol; y < rol + k; y++) ++size[cc[x][y]];
  }
  printf("%d\n", best);
  return 0;
}
