#include <bits/stdc++.h>
using namespace std;
using INT = long long;
static char fjf[1010];
char gc() {
  static char *L = fjf, *R = L;
  if (L == R) {
    int n = fread(fjf, 1, 1010, stdin);
    if (!n) return -1;
    L = fjf, R = L + n;
  }
  return *L++;
}
void gn(int &x) {
  char c;
  while (c = gc(), (c < 48 || 57 < c) && ~c)
    ;
  for (x = c - 48; c = gc(), 48 <= c && c <= 57; x = 10 * x + c - 48)
    ;
}
void gn(char *s) {
  char c;
  while (c = gc(), ~c && isspace(c))
    ;
  for (*s++ = c; c = gc(), ~c && !isspace(c); *s++ = c)
    ;
}
char s[505][505];
int id[505][505], dp[505][505];
int root[252525], sz[252525], n, k;
int num[252525], vst[252525], runs;
bool out(int u, int v) { return u < 1 || v < 1 || u > n || v > n; }
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int calc(int x, int y) {
  return dp[x - 1][y - 1] - dp[x - 1][y - k + 1] - dp[x - k + 1][y - 1] +
         dp[x - k + 1][y - k + 1];
}
int find(int u) {
  if (u == root[u]) return u;
  return root[u] = find(root[u]);
}
INT sum;
void insert(int x, int y) {
  if (s[x][y] == '.') {
    int u = find(id[x][y]);
    if (vst[u] != runs) vst[u] = runs, num[u] = 0;
    if (!num[u]++) sum += sz[u];
  }
}
void erase(int x, int y) {
  if (s[x][y] == '.') {
    int u = find(id[x][y]);
    if (!--num[u]) sum -= sz[u];
  }
}
int main() {
  gn(n), gn(k), n += 2, k += 2;
  for (int i = 1; i <= n; i++) s[1][i] = s[n][i] = 'X';
  for (int i = 2; i < n; i++) {
    gn(s[i] + 2);
    s[i][1] = s[i][n] = 'X';
  }
  int N = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      id[i][j] = ++N, root[N] = N, sz[N] = 1;
      dp[i][j] =
          dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + (s[i][j] == 'X');
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (s[i][j] == '.') {
        for (int k = 4; k--;) {
          int x = i + dx[k], y = j + dy[k];
          if (out(x, y) || s[x][y] == 'X') continue;
          int u = find(id[i][j]);
          int v = find(id[x][y]);
          if (u != v) {
            root[u] = v, sz[v] += sz[u];
          }
        }
      }
  }
  INT ans = 0;
  for (int I = 0; I + k <= n; I++) {
    runs++, sum = 0;
    for (int i = 1; i <= k; i++) {
      for (int j = 1; j <= k; j++) {
        insert(I + i, j);
      }
    }
    for (int j = k; j <= n; j++) {
      erase(I + 1, j - k + 1), erase(I + 1, j);
      erase(I + k, j - k + 1), erase(I + k, j);
      ans = max(ans, sum + calc(I + k, j));
      insert(I + 1, j - k + 1), insert(I + 1, j);
      insert(I + k, j - k + 1), insert(I + k, j);
      for (int i = 1; i <= k; i++) {
        erase(I + i, j - k + 1), insert(I + i, j + 1);
      }
    }
  }
  printf("%I64d", ans);
}
