#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
static void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static void amax(T &x, U y) {
  if (x < y) x = y;
}
int mod1 = int(1e9) + 7;
char s[505];
int b[505][505];
int bid[505][505];
int comp[250005];
int cnt[250005];
int dc[] = {1, 0, -1, 0};
int dr[] = {0, 1, 0, -1};
vector<int> cid;
int n, k;
void dfs(int r, int c, int pr, int pc, int id) {
  bid[r][c] = id;
  comp[id]++;
  for (int i = 0; i < (int)(4); ++i) {
    int rr = r + dr[i];
    int cc = c + dc[i];
    if (rr == pr && cc == pc) continue;
    if (rr < 1 || rr > n || cc < 1 || cc > n || b[rr][cc] == 1 ||
        bid[rr][cc] > 0)
      continue;
    dfs(rr, cc, r, c, id);
  }
}
int getc(int r, int c) {
  if (r < 1 || r > n || c < 1 || c > n || b[r][c] == 1 || cnt[bid[r][c]] == 1)
    return 0;
  cnt[bid[r][c]] = 1;
  cid.push_back(bid[r][c]);
  return comp[bid[r][c]];
}
int main() {
  scanf("%d%d", &(n), &(k));
  for (int i = 1; i <= (int)(n); ++i) {
    scanf("%s", s);
    for (int j = 1; j <= (int)(n); ++j) b[i][j] = s[j - 1] == '.' ? 0 : 1;
  }
  int id = 1;
  for (int r = 1; r <= (int)(n); ++r)
    for (int c = 1; c <= (int)(n); ++c) {
      if (b[r][c] || bid[r][c] > 0)
        continue;
      else {
        dfs(r, c, 0, 0, id);
        id++;
      }
    }
  for (int r = 1; r <= (int)(k); ++r)
    for (int c = 1; c <= (int)(k); ++c) {
      if (b[r][c] == 0) {
        comp[bid[r][c]]--;
      }
    }
  int ans = 0;
  for (int rr = 1; rr <= (int)(n - k + 1); ++rr) {
    int cc;
    for (int it = 0; it < (int)(n - k + 1); ++it) {
      cc = rr % 2 ? 1 + it : n - k + 1 - it;
      int out = 0;
      for (int c = cc; c < cc + k; c++) {
        int r = rr - 1;
        out += getc(r, c);
      }
      for (int r = rr; r < rr + k; r++) {
        int c = cc + k;
        out += getc(r, c);
      }
      for (int c = cc + k - 1; c >= cc; c--) {
        int r = rr + k;
        out += getc(r, c);
      }
      for (int r = rr + k - 1; r >= rr; r--) {
        int c = cc - 1;
        out += getc(r, c);
      }
      amax(ans, k * k + out);
      for (int i = 0; i < (int)(cid.size()); ++i) {
        cnt[cid[i]] = 0;
      }
      cid.clear();
      int cdel = rr % 2 ? cc : cc + k - 1;
      int cadd = rr % 2 ? cc + k : cc - 1;
      for (int r = rr; r < rr + k; r++) {
        if (1 <= cadd && cadd <= n) {
          if (b[r][cdel] == 0) {
            comp[bid[r][cdel]]++;
          }
          if (b[r][cadd] == 0) {
            comp[bid[r][cadd]]--;
          }
        }
      }
    }
    for (int c = cc; c < cc + k; c++) {
      if (b[rr][c] == 0) {
        comp[bid[rr][c]]++;
      }
      if (rr + k <= n && b[rr + k][c] == 0) {
        comp[bid[rr + k][c]]--;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
