#include <bits/stdc++.h>
using namespace std;
queue<int> Q;
char s[505][505];
int Map[505 * 505];
bool Set[505 * 505];
int vis[505 * 505], num[505 * 505], cnt, n,
    dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void bfs(int S) {
  Q.push(S);
  vis[S] = ++cnt;
  ++num[cnt];
  int u, x, y, xx, yy, v;
  while (!Q.empty()) {
    u = Q.front();
    Q.pop();
    x = u / n;
    y = u % n;
    for (int i = 0; i < 4; ++i) {
      xx = x + dir[i][0];
      yy = y + dir[i][1];
      if ((xx >= 0 && yy >= 0 && xx < n && yy < n) && s[xx][yy] == '.') {
        v = xx * n + yy;
        if (!vis[v]) {
          Q.push(v);
          ++num[cnt];
          vis[v] = cnt;
        }
      }
    }
  }
}
int main() {
  int k, ans, res, tmp;
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);
    if (k == n) {
      printf("%d\n", n * n);
      continue;
    }
    memset(vis, 0, sizeof(vis));
    memset(num, 0, sizeof(num));
    cnt = 0;
    ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (s[i][j] == '.' && vis[i * n + j] == 0) bfs(i * n + j);
      }
    }
    for (int i = 0; i + k <= n; ++i) {
      memset(Map, 0, sizeof(Map));
      memset(Set, false, sizeof(Set));
      for (int j = i; j < k + i; ++j) {
        for (int l = 0; l < k; ++l) {
          if (s[j][l] == '.' && vis[j * n + l] != 0) ++Map[vis[j * n + l]];
        }
      }
      for (int j = 0; j < k; ++j) {
        if (i > 0) {
          Q.push(tmp = vis[(i - 1) * n + j]);
          Set[tmp] = true;
        }
        if (i + k < n) {
          Q.push(tmp = vis[(i + k) * n + j]);
          Set[tmp] = true;
        }
        Q.push(tmp = vis[(j + i) * n + k]);
        Set[tmp] = true;
      }
      res = k * k;
      while (!Q.empty()) {
        tmp = Q.front();
        Q.pop();
        if (Set[tmp]) {
          if (tmp != 0) {
            res += num[tmp];
            res -= Map[tmp];
          }
          Set[tmp] = false;
        }
      }
      if (ans < res) ans = res;
      for (int j = 1; j + k <= n; ++j) {
        for (int l = i; l < i + k; ++l) {
          --Map[vis[j - 1 + l * n]];
          ++Map[vis[l * n + j + k - 1]];
        }
        for (int l = 0; l < k; ++l) {
          if (i > 0) {
            Q.push(tmp = vis[(i - 1) * n + j + l]);
            Set[tmp] = true;
          }
          if (i + k < n) {
            Q.push(tmp = vis[(i + k) * n + l + j]);
            Set[tmp] = true;
          }
          Q.push(tmp = vis[(l + i) * n + j - 1]);
          Set[tmp] = true;
          if (j + k < n) {
            Q.push(tmp = vis[(l + i) * n + j + k]);
            Set[tmp] = true;
          }
        }
        res = k * k;
        while (!Q.empty()) {
          tmp = Q.front();
          Q.pop();
          if (Set[tmp]) {
            if (tmp != 0) {
              res += num[tmp];
              res -= Map[tmp];
            }
            Set[tmp] = false;
          }
        }
        if (ans < res) ans = res;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
